mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 15:15:34 +00:00
Only show modifications icon if the module has valid modifications. Use no more than two decimal places for modification values.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Slot from './Slot';
|
import Slot from './Slot';
|
||||||
import { DamageKinetic, DamageThermal, DamageExplosive, MountFixed, MountGimballed, MountTurret, Modifications } from './SvgIcons';
|
import { DamageKinetic, DamageThermal, DamageExplosive, MountFixed, MountGimballed, MountTurret, ListModifications } from './SvgIcons';
|
||||||
|
import { Modifications } from 'coriolis-data/dist';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hardpoint / Utility Slot
|
* Hardpoint / Utility Slot
|
||||||
@@ -36,6 +38,7 @@ export default class HardpointSlot extends Slot {
|
|||||||
if (m) {
|
if (m) {
|
||||||
let classRating = `${m.class}${m.rating}${m.missile ? '/' + m.missile : ''}`;
|
let classRating = `${m.class}${m.rating}${m.missile ? '/' + m.missile : ''}`;
|
||||||
let { drag, drop } = this.props;
|
let { drag, drop } = this.props;
|
||||||
|
let validMods = Modifications.validity[m.grp] || [];
|
||||||
|
|
||||||
return <div className='details' draggable='true' onDragStart={drag} onDragEnd={drop}>
|
return <div className='details' draggable='true' onDragStart={drag} onDragEnd={drop}>
|
||||||
<div className={'cb'}>
|
<div className={'cb'}>
|
||||||
@@ -59,7 +62,7 @@ export default class HardpointSlot extends Slot {
|
|||||||
{ m.range && !m.dps ? <div className={'l'}>{translate('Range')} : {formats.round(m.range / 1000)}{u.km}</div> : null }
|
{ m.range && !m.dps ? <div className={'l'}>{translate('Range')} : {formats.round(m.range / 1000)}{u.km}</div> : null }
|
||||||
{ m.shieldmul ? <div className={'l'}>+{formats.rPct(m.shieldmul)}</div> : null }
|
{ m.shieldmul ? <div className={'l'}>+{formats.rPct(m.shieldmul)}</div> : null }
|
||||||
{ m.ammo >= 0 ? <div className={'l'}>{translate('ammo')}: {formats.int(m.clip)}/{formats.int(m.ammo)}</div> : null }
|
{ m.ammo >= 0 ? <div className={'l'}>{translate('ammo')}: {formats.int(m.clip)}/{formats.int(m.ammo)}</div> : null }
|
||||||
<div className={'r'}><Modifications /></div>
|
{ validMods.length > 0 ? <div className='r' ><ListModifications /></div> : null }
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Slot from './Slot';
|
import Slot from './Slot';
|
||||||
import { Modifications } from './SvgIcons';
|
import { ListModifications } from './SvgIcons';
|
||||||
|
import { Modifications } from 'coriolis-data/dist';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal Slot
|
* Internal Slot
|
||||||
@@ -19,6 +20,7 @@ export default class InternalSlot extends Slot {
|
|||||||
if (m) {
|
if (m) {
|
||||||
let classRating = m.class + m.rating;
|
let classRating = m.class + m.rating;
|
||||||
let { drag, drop } = this.props;
|
let { drag, drop } = this.props;
|
||||||
|
let validMods = Modifications.validity[m.grp] || [];
|
||||||
|
|
||||||
return <div className='details' draggable='true' onDragStart={drag} onDragEnd={drop}>
|
return <div className='details' draggable='true' onDragStart={drag} onDragEnd={drop}>
|
||||||
<div className={'cb'}>
|
<div className={'cb'}>
|
||||||
@@ -42,7 +44,7 @@ export default class InternalSlot extends Slot {
|
|||||||
{ m.rangeLS === null ? <div className={'l'}>∞{u.Ls}</div> : null }
|
{ m.rangeLS === null ? <div className={'l'}>∞{u.Ls}</div> : null }
|
||||||
{ m.rangeRating ? <div className={'l'}>{translate('range')}: {m.rangeRating}</div> : null }
|
{ m.rangeRating ? <div className={'l'}>{translate('range')}: {m.rangeRating}</div> : null }
|
||||||
{ m.armouradd ? <div className={'l'}>+{m.armouradd} <u className='cap'>{translate('armour')}</u></div> : null }
|
{ m.armouradd ? <div className={'l'}>+{m.armouradd} <u className='cap'>{translate('armour')}</u></div> : null }
|
||||||
<div className={'r'}><Modifications /></div>
|
{ validMods.length > 0 ? <div className='r' ><ListModifications /></div> : null }
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import TranslatedComponent from './TranslatedComponent';
|
|||||||
import { jumpRange } from '../shipyard/Calculations';
|
import { jumpRange } from '../shipyard/Calculations';
|
||||||
import { diffDetails } from '../utils/SlotFunctions';
|
import { diffDetails } from '../utils/SlotFunctions';
|
||||||
import AvailableModulesMenu from './AvailableModulesMenu';
|
import AvailableModulesMenu from './AvailableModulesMenu';
|
||||||
import { Modifications } from './SvgIcons';
|
import { ListModifications } from './SvgIcons';
|
||||||
import Slider from './Slider';
|
import Slider from './Slider';
|
||||||
|
import { Modifications } from 'coriolis-data/dist';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Slot
|
* Standard Slot
|
||||||
@@ -33,6 +34,7 @@ export default class StandardSlot extends TranslatedComponent {
|
|||||||
let m = slot.m;
|
let m = slot.m;
|
||||||
let classRating = m.class + m.rating;
|
let classRating = m.class + m.rating;
|
||||||
let menu;
|
let menu;
|
||||||
|
let validMods = m == null ? [] : (Modifications.validity[m.grp] || []);
|
||||||
|
|
||||||
if (this.props.selected) {
|
if (this.props.selected) {
|
||||||
menu = <AvailableModulesMenu
|
menu = <AvailableModulesMenu
|
||||||
@@ -66,10 +68,7 @@ export default class StandardSlot extends TranslatedComponent {
|
|||||||
{ m.weaponcapacity ? <div className='l'>{translate('WEP')}: {m.weaponcapacity}{units.MJ} / {m.weaponrecharge}{units.MW}</div> : null }
|
{ m.weaponcapacity ? <div className='l'>{translate('WEP')}: {m.weaponcapacity}{units.MJ} / {m.weaponrecharge}{units.MW}</div> : null }
|
||||||
{ m.systemcapacity ? <div className='l'>{translate('SYS')}: {m.systemcapacity}{units.MJ} / {m.systemrecharge}{units.MW}</div> : null }
|
{ m.systemcapacity ? <div className='l'>{translate('SYS')}: {m.systemcapacity}{units.MJ} / {m.systemrecharge}{units.MW}</div> : null }
|
||||||
{ m.enginecapacity ? <div className='l'>{translate('ENG')}: {m.enginecapacity}{units.MJ} / {m.enginerecharge}{units.MW}</div> : null }
|
{ m.enginecapacity ? <div className='l'>{translate('ENG')}: {m.enginecapacity}{units.MJ} / {m.enginerecharge}{units.MW}</div> : null }
|
||||||
<div className={'r'}><Modifications /></div>
|
{ validMods.length > 0 ? <div className='r' ><ListModifications /></div> : null }
|
||||||
</div>
|
|
||||||
<div className={'cb'} >
|
|
||||||
<Slider onChange={this._updateSliderValue.bind(this)} min={-1} max={1} percent={this._getSliderValue()} />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -77,10 +76,12 @@ export default class StandardSlot extends TranslatedComponent {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// {validMods.length > 0 ? <div className='cb' ><Slider onChange={this._updateSliderValue.bind(this)} min={-1} max={1} percent={this._getSliderValue()}/></div> : null }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update power usage modification given a slider value.
|
* Update power usage modification given a slider value.
|
||||||
* Note that this is a temporary function until we have a slider section
|
* Note that this is a temporary function until we have a slider section
|
||||||
|
* @param {Number} value The value of the slider
|
||||||
*/
|
*/
|
||||||
_updateSliderValue(value) {
|
_updateSliderValue(value) {
|
||||||
let m = this.props.slot.m;
|
let m = this.props.slot.m;
|
||||||
@@ -93,6 +94,7 @@ export default class StandardSlot extends TranslatedComponent {
|
|||||||
/**
|
/**
|
||||||
* Obtain slider value from a power usage modification.
|
* Obtain slider value from a power usage modification.
|
||||||
* Note that this is a temporary function until we have a slider section
|
* Note that this is a temporary function until we have a slider section
|
||||||
|
* @return {Number} value The value of the slider
|
||||||
*/
|
*/
|
||||||
_getSliderValue() {
|
_getSliderValue() {
|
||||||
let m = this.props.slot.m;
|
let m = this.props.slot.m;
|
||||||
|
|||||||
@@ -489,9 +489,9 @@ export class Rocket extends SvgIcon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifications (engineers)
|
* ListModifications (engineers)
|
||||||
*/
|
*/
|
||||||
export class Modifications extends SvgIcon {
|
export class ListModifications extends SvgIcon {
|
||||||
/**
|
/**
|
||||||
* Overriden view box
|
* Overriden view box
|
||||||
* @return {String} view box
|
* @return {String} view box
|
||||||
|
|||||||
@@ -32,20 +32,20 @@ export default class Module {
|
|||||||
* @return {Number} The value of the modification, as a decimal value from -1 to 1
|
* @return {Number} The value of the modification, as a decimal value from -1 to 1
|
||||||
*/
|
*/
|
||||||
getModValue(modId) {
|
getModValue(modId) {
|
||||||
return this.mods ? this.mods[modId] / 100000 : null;
|
return this.mods ? this.mods[modId] / 10000 : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a value for a given modification ID
|
* Set a value for a given modification ID
|
||||||
* @param {Number} modId The ID of the modification
|
* @param {Number} modId The ID of the modification
|
||||||
* @param {Number} val The value of the modification, as a decimal value from -1 to 1
|
* @param {Number} value The value of the modification, as a decimal value from -1 to 1
|
||||||
*/
|
*/
|
||||||
setModValue(modId, value) {
|
setModValue(modId, value) {
|
||||||
if (value == null || value == 0) {
|
if (value == null || value == 0) {
|
||||||
delete this.mods[modId];
|
delete this.mods[modId];
|
||||||
} else {
|
} else {
|
||||||
// Store value with 3dp
|
// Store value with 2dp
|
||||||
this.mods[modId] = Math.round(value * 100000);
|
this.mods[modId] = Math.round(value * 10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ export default class Ship {
|
|||||||
|
|
||||||
this.bulkheads.m = null;
|
this.bulkheads.m = null;
|
||||||
this.useBulkhead(comps && comps.bulkheads ? comps.bulkheads : 0, true);
|
this.useBulkhead(comps && comps.bulkheads ? comps.bulkheads : 0, true);
|
||||||
this.bulkheads.m.mods = mods && mods[0] ? mods[0] : {}
|
this.bulkheads.m.mods = mods && mods[0] ? mods[0] : {};
|
||||||
this.cargoHatch.priority = priorities ? priorities[0] * 1 : 0;
|
this.cargoHatch.priority = priorities ? priorities[0] * 1 : 0;
|
||||||
this.cargoHatch.enabled = enabled ? enabled[0] * 1 : true;
|
this.cargoHatch.enabled = enabled ? enabled[0] * 1 : true;
|
||||||
this.cargoHatch.mods = mods ? mods[0] : {};
|
this.cargoHatch.mods = mods ? mods[0] : {};
|
||||||
@@ -896,8 +896,8 @@ export default class Ship {
|
|||||||
|
|
||||||
let bulkheadMods = new Array();
|
let bulkheadMods = new Array();
|
||||||
if (this.bulkheads.m && this.bulkheads.m.mods) {
|
if (this.bulkheads.m && this.bulkheads.m.mods) {
|
||||||
for (var modKey in this.bulkheads.m.mods) {
|
for (let modKey in this.bulkheads.m.mods) {
|
||||||
bulkheadMods.push(modKey + ':' + Math.round(this.bulkheads.m.getModValue(modKey) * 100000));
|
bulkheadMods.push(modKey + ':' + Math.round(this.bulkheads.m.getModValue(modKey) * 10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allMods.push(bulkheadMods.join(';'));
|
allMods.push(bulkheadMods.join(';'));
|
||||||
@@ -905,8 +905,8 @@ export default class Ship {
|
|||||||
for (let slot of this.standard) {
|
for (let slot of this.standard) {
|
||||||
let slotMods = new Array();
|
let slotMods = new Array();
|
||||||
if (slot.m && slot.m.mods) {
|
if (slot.m && slot.m.mods) {
|
||||||
for (var modKey in slot.m.mods) {
|
for (let modKey in slot.m.mods) {
|
||||||
slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 100000));
|
slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allMods.push(slotMods.join(';'));
|
allMods.push(slotMods.join(';'));
|
||||||
@@ -914,8 +914,8 @@ export default class Ship {
|
|||||||
for (let slot of this.hardpoints) {
|
for (let slot of this.hardpoints) {
|
||||||
let slotMods = new Array();
|
let slotMods = new Array();
|
||||||
if (slot.m && slot.m.mods) {
|
if (slot.m && slot.m.mods) {
|
||||||
for (var modKey in slot.m.mods) {
|
for (let modKey in slot.m.mods) {
|
||||||
slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 100000));
|
slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allMods.push(slotMods.join(';'));
|
allMods.push(slotMods.join(';'));
|
||||||
@@ -923,8 +923,8 @@ export default class Ship {
|
|||||||
for (let slot of this.internal) {
|
for (let slot of this.internal) {
|
||||||
let slotMods = new Array();
|
let slotMods = new Array();
|
||||||
if (slot.m && slot.m.mods) {
|
if (slot.m && slot.m.mods) {
|
||||||
for (var modKey in slot.m.mods) {
|
for (let modKey in slot.m.mods) {
|
||||||
slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 100000));
|
slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allMods.push(slotMods.join(';'));
|
allMods.push(slotMods.join(';'));
|
||||||
|
|||||||
Reference in New Issue
Block a user