diff --git a/src/app/components/OutfittingSubpages.jsx b/src/app/components/OutfittingSubpages.jsx
index 33b3fe6d..8f8b8ecc 100644
--- a/src/app/components/OutfittingSubpages.jsx
+++ b/src/app/components/OutfittingSubpages.jsx
@@ -11,30 +11,24 @@ import Movement from './Movement';
import Offence from './Offence';
import Defence from './Defence';
import WeaponDamageChart from './WeaponDamageChart';
+import Pips from '../components/Pips';
+import Boost from '../components/Boost';
+import Fuel from '../components/Fuel';
+import Cargo from '../components/Cargo';
+import ShipPicker from '../components/ShipPicker';
+import EngagementRange from '../components/EngagementRange';
import autoBind from 'auto-bind';
+import { ShipProps } from 'ed-forge';
+const { CARGO_CAPACITY, FUEL_CAPACITY } = ShipProps;
/**
* Outfitting subpages
*/
export default class OutfittingSubpages extends TranslatedComponent {
-
static propTypes = {
ship: PropTypes.object.isRequired,
code: PropTypes.string.isRequired,
- onChange: PropTypes.func.isRequired,
buildName: PropTypes.string,
- sys: PropTypes.number.isRequired,
- eng: PropTypes.number.isRequired,
- wep: PropTypes.number.isRequired,
- cargo: PropTypes.number.isRequired,
- fuel: PropTypes.number.isRequired,
- boost: PropTypes.bool.isRequired,
- engagementRange: PropTypes.number.isRequired,
- opponent: PropTypes.object.isRequired,
- opponentBuild: PropTypes.string,
- opponentSys: PropTypes.number.isRequired,
- opponentEng: PropTypes.number.isRequired,
- opponentWep: PropTypes.number.isRequired,
};
/**
@@ -45,8 +39,15 @@ export default class OutfittingSubpages extends TranslatedComponent {
super(props);
autoBind(this);
+ this.props.ship.setOpponent(this.props.ship);
this.state = {
+ boost: false,
+ cargo: props.ship.get(CARGO_CAPACITY),
+ fuel: props.ship.get(FUEL_CAPACITY),
+ pips: props.ship.getDistributorSettingsObject(),
tab: Persist.getOutfittingTab() || 'power',
+ engagementRange: 1000,
+ opponent: this.props.ship,
};
}
@@ -55,128 +56,114 @@ export default class OutfittingSubpages extends TranslatedComponent {
* @param {string} tab Tab name
*/
_showTab(tab) {
+ Persist.setOutfittingTab(tab);
this.setState({ tab });
}
- /**
- * Render the power tab
- * @return {React.Component} Tab contents
- */
- _powerTab() {
- let { ship, buildName, code, onChange } = this.props;
- Persist.setOutfittingTab('power');
-
- const powerMarker = `${ship.toString()}`;
- const costMarker = `${ship.toString().split('.')[0]}`;
-
- return
;
- }
-
- /**
- * Render the profiles tab
- * @return {React.Component} Tab contents
- */
- _profilesTab() {
- const { ship, opponent, cargo, fuel, eng, boost, engagementRange, opponentSys } = this.props;
- const { translate } = this.context.language;
- let realBoost = boost && ship.canBoost(cargo, fuel);
- Persist.setOutfittingTab('profiles');
-
- const engineProfileMarker = `${ship.toString()}:${cargo}:${fuel}:${eng}:${realBoost}`;
- const fsdProfileMarker = `${ship.toString()}:${cargo}:${fuel}`;
- const movementMarker = `${ship.topSpeed}:${ship.pitch}:${ship.roll}:${ship.yaw}:${ship.canBoost(cargo, fuel)}`;
- const damageMarker = `${ship.toString()}:${opponent.toString()}:${engagementRange}:${opponentSys}`;
-
- return
-
-
{translate('engine profile')}
-
-
-
-
-
{translate('fsd profile')}
-
-
-
-
-
{translate('movement profile')}
-
-
-
-
-
{translate('damage to opponent\'s shields')}
-
-
-
-
-
{translate('damage to opponent\'s hull')}
-
-
-
;
- }
-
- /**
- * Render the offence tab
- * @return {React.Component} Tab contents
- */
- _offenceTab() {
- const { ship, sys, eng, wep, cargo, fuel, boost, engagementRange, opponent, opponentBuild, opponentSys } = this.props;
- Persist.setOutfittingTab('offence');
-
- const marker = `${ship.toString()}${opponent.toString()}${opponentBuild}${engagementRange}${opponentSys}`;
-
- return
-
-
;
- }
-
- /**
- * Render the defence tab
- * @return {React.Component} Tab contents
- */
- _defenceTab() {
- const { ship, sys, eng, wep, cargo, fuel, boost, engagementRange, opponent, opponentBuild, opponentWep } = this.props;
- Persist.setOutfittingTab('defence');
-
- const marker = `${ship.toString()}${opponent.toString()}{opponentBuild}${engagementRange}${opponentWep}`;
-
- return
-
-
;
- }
-
/**
* Render the section
* @return {React.Component} Contents
*/
render() {
- const tab = this.state.tab;
- const translate = this.context.language.translate;
- let tabSection;
-
- switch (tab) {
- case 'power': tabSection = this._powerTab(); break;
- case 'profiles': tabSection = this._profilesTab(); break;
- case 'offence': tabSection = this._offenceTab(); break;
- case 'defence': tabSection = this._defenceTab(); break;
- }
+ const { buildName, code, ship } = this.props;
+ const { boost, cargo, fuel, pips, tab, engagementRange, opponent } = this.state;
+ const { translate } = this.context.language;
+ const cargoCapacity = ship.get(CARGO_CAPACITY);
+ const showCargoSlider = cargoCapacity > 0;
return (
-
-
-
-
- | {translate('power and costs')} |
- {translate('profiles')} |
- {translate('offence')} |
- {translate('tab_defence')} |
-
-
-
- {tabSection}
+
+ {/* Control of ship and opponent */}
+
+
+ {translate('ship control')}
+
+ this.setState({ boost })} />
+
+
+
+ {translate('opponent')}
+
+ this.setState({ opponent })} />
+
+
+ this.setState({ fuel })} />
+
+ {showCargoSlider ?
+
+ this.setState({ cargo })} />
+
: null}
+
+
this.setState({ pips })} />
+
+
+ this.setState({ engagementRange })} />
+
+
+
+ {/* Select tab section */}
+
+
+ |
+ {translate('power and costs')}
+ |
+
+ {translate('profiles')} |
+
+ {translate('offence')}
+ |
+
+ {translate('tab_defence')}
+ |
+
+
+
+ {/* Show selected tab */}
+ {tab == 'power' ?
+
: null}
+ {tab == 'profiles' ?
+
+
+
{translate('engine profile')}
+
+
+
+
{translate('fsd profile')}
+
+
+
+
{translate('movement profile')}
+
+
+
+
{translate('damage to opponent\'s shields')}
+
+
+
+
+
{translate('damage to opponent\'s hull')}
+
+
+
: null}
+ {tab == 'offence' ?
+
+
+
: null}
+ {tab == 'defence' ?
+
+
+
: null}
+
);
}