import React from 'react'; import cn from 'classnames'; import Slot from './Slot'; import Persist from '../stores/Persist'; import { ListModifications, Modified } from './SvgIcons'; import { Modifications } from 'coriolis-data/dist'; import { stopCtxPropagation } from '../utils/UtilityFunctions'; import { blueprintTooltip } from '../utils/BlueprintFunctions'; /** * Internal Slot */ export default class InternalSlot extends Slot { /** * Generate the slot contents * @param {Object} m Mounted Module * @param {Boolean} enabled Slot enabled * @param {Function} translate Translate function * @param {Object} formats Localized Formats map * @param {Object} u Localized Units Map * @return {React.Component} Slot contents */ _getSlotDetails(m, enabled, translate, formats, u) { if (m) { let classRating = m.class + m.rating; let { drag, drop, ship } = this.props; let { termtip, tooltip } = this.context; let validMods = (Modifications.modules[m.grp] ? Modifications.modules[m.grp].modifications : []); let showModuleResistances = Persist.showModuleResistances(); // Modifications tooltip shows blueprint and grade, if available let modTT = translate('modified'); if (m && m.blueprint && m.blueprint.name) { modTT = translate(m.blueprint.name) + ' ' + translate('grade') + ' ' + m.blueprint.grade; if (m.blueprint.special && m.blueprint.special.id >= 0) { modTT += ', ' + translate(m.blueprint.special.name); } modTT = (
{modTT}
{blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], null, m.grp, m)}
); } let mass = m.getMass() || m.cargo || m.fuel || 0; const className = cn('details', enabled ? '' : 'disabled'); return
{classRating} {translate(m.name || m.grp)}{m.mods && Object.keys(m.mods).length > 0 ? : ''}
{formats.round(mass)}{u.T}
{ m.getOptMass() ?
{translate('optmass', 'sg')}: {formats.int(m.getOptMass())}{u.T}
: null } { m.getMaxMass() ?
{translate('maxmass', 'sg')}: {formats.int(m.getMaxMass())}{u.T}
: null } { m.bins ?
{m.bins} {translate('bins')}
: null } { m.bays ?
{translate('bays')}: {m.bays}
: null } { m.rebuildsperbay ?
{translate('rebuildsperbay')}: {m.rebuildsperbay}
: null } { m.rate ?
{translate('rate')}: {m.rate}{u.kgs}   {translate('refuel time')}: {formats.time(this.props.fuel * 1000 / m.rate)}
: null } { m.getAmmo() && m.grp !== 'scb' ?
{translate('ammunition')}: {formats.gen(m.getAmmo())}
: null } { m.getSpinup() ?
{translate('spinup')}: {formats.f1(m.getSpinup())}{u.s}
: null } { m.getDuration() ?
{translate('duration')}: {formats.f1(m.getDuration())}{u.s}
: null } { m.grp === 'scb' ?
{translate('cells')}: {formats.int(m.getAmmo() + 1)}
: null } { m.grp === 'gsrp' ?
{translate('shield addition')}: {formats.f1(m.getShieldAddition())}{u.MJ}
: null } { m.grp === 'gfsb' ?
{translate('jump addition')}: {formats.f1(m.getJumpBoost())}{u.LY}
: null } { m.grp === 'gs' ?
{translate('shield addition')}: {formats.f1(m.getShieldAddition())}{u.MJ}
: null } { m.getShieldReinforcement() ?
{translate('shieldreinforcement')}: {formats.f1(m.getDuration() * m.getShieldReinforcement())}{u.MJ}
: null } { m.getShieldReinforcement() ?
{translate('total')}: {formats.int((m.getAmmo() + 1) * (m.getDuration() * m.getShieldReinforcement()))}{u.MJ}
: null } { m.repair ?
{translate('repair')}: {m.repair}
: null } { m.getFacingLimit() ?
{translate('facinglimit')} {formats.f1(m.getFacingLimit())}°
: null } { m.getRange() ?
{translate('range')} {formats.f2(m.getRange())}{u.km}
: null } { m.getRangeT() ?
{translate('ranget')} {formats.f1(m.getRangeT())}{u.s}
: null } { m.getTime() ?
{translate('time')}: {formats.time(m.getTime())}
: null } { m.getHackTime() ?
{translate('hacktime')}: {formats.time(m.getHackTime())}
: null } { m.maximum ?
{translate('max')}: {(m.maximum)}
: null } { m.rangeLS ?
{translate('range')}: {m.rangeLS}{u.Ls}
: null } { m.rangeLS === null ?
∞{u.Ls}
: null } { m.rangeRating ?
{translate('range')}: {m.rangeRating}
: null } { m.passengers ?
{translate('passengers')}: {m.passengers}
: null } { m.getRegenerationRate() ?
{translate('regen')}: {formats.round1(m.getRegenerationRate())}{u.ps}
: null } { m.getBrokenRegenerationRate() ?
{translate('brokenregen')}: {formats.round1(m.getBrokenRegenerationRate())}{u.ps}
: null } { showModuleResistances && m.getExplosiveResistance() ?
{translate('explres')}: {formats.pct(m.getExplosiveResistance())}
: null } { showModuleResistances && m.getKineticResistance() ?
{translate('kinres')}: {formats.pct(m.getKineticResistance())}
: null } { showModuleResistances && m.getThermalResistance() ?
{translate('thermres')}: {formats.pct(m.getThermalResistance())}
: null } { showModuleResistances && m.getCausticResistance() ?
{translate('causres')}: {formats.pct(m.getCausticResistance())}
: null } { m.getHullReinforcement() ?
{translate('armour')}: {formats.int(m.getHullReinforcement() + ship.baseArmour * m.getModValue('hullboost') / 10000)}
: null } { m.getProtection() ?
{translate('protection')}: {formats.rPct(m.getProtection())}
: null } { m.getIntegrity() ?
{translate('integrity')}: {formats.int(m.getIntegrity())}
: null } { m.getInfo() ?
{translate(m.getInfo())}
: null } { m && validMods.length > 0 ?
this.modButton = modButton }>
: null }
; } else { return
{translate('empty')}
; } } }