mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-11 16:53:02 +00:00
Use ship rather than ship ID
This commit is contained in:
@@ -124,7 +124,7 @@ export default class DamageDealt extends TranslatedComponent {
|
|||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<h1>{translate('damage dealt against')}</h1>
|
<h1>{translate('damage dealt against')}</h1>
|
||||||
<ShipSelector currentMenu={this.props.currentMenu} onChange={this._onShipChange} />
|
<ShipSelector initial={this.state.against} currentMenu={this.props.currentMenu} onChange={this._onShipChange} />
|
||||||
<table style={{ width: '100%' }}>
|
<table style={{ width: '100%' }}>
|
||||||
<thead>
|
<thead>
|
||||||
<tr className='main'>
|
<tr className='main'>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { Rocket } from './SvgIcons';
|
|||||||
*/
|
*/
|
||||||
export default class ShipSelector extends TranslatedComponent {
|
export default class ShipSelector extends TranslatedComponent {
|
||||||
static PropTypes = {
|
static PropTypes = {
|
||||||
|
initial: React.PropTypes.object.isRequired,
|
||||||
onChange: React.PropTypes.func.isRequired
|
onChange: React.PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ export default class ShipSelector extends TranslatedComponent {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = { shipId : 'adder' };
|
this.state = { ship : this.props.initial };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,7 +59,7 @@ export default class ShipSelector extends TranslatedComponent {
|
|||||||
* @param {string} s The selected ship ID
|
* @param {string} s The selected ship ID
|
||||||
*/
|
*/
|
||||||
_selectShip(s) {
|
_selectShip(s) {
|
||||||
this.setState({ shipId: s });
|
this.setState({ ship: Ships[s] });
|
||||||
|
|
||||||
this.context.openMenu(null);
|
this.context.openMenu(null);
|
||||||
this.props.onChange(s);
|
this.props.onChange(s);
|
||||||
@@ -70,13 +71,13 @@ export default class ShipSelector extends TranslatedComponent {
|
|||||||
*/
|
*/
|
||||||
render() {
|
render() {
|
||||||
const currentMenu = this.props.currentMenu;
|
const currentMenu = this.props.currentMenu;
|
||||||
const shipId = this.state.shipId;
|
const ship = this.state.ship;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='shipselector'>
|
<div className='shipselector'>
|
||||||
<div className='menu'>
|
<div className='menu'>
|
||||||
<div className={cn('menu-header', { selected: currentMenu == 'wds' })} onClick={this._openMenu.bind(this, 'wds')}>
|
<div className={cn('menu-header', { selected: currentMenu == 'wds' })} onClick={this._openMenu.bind(this, 'wds')}>
|
||||||
<Rocket className='warning' /><span className='menu-item-label'>{Ships[shipId].properties.name}</span>
|
<Rocket className='warning' /><span className='menu-item-label'>{ship.properties.name}</span>
|
||||||
{currentMenu == 'wds' ?
|
{currentMenu == 'wds' ?
|
||||||
<div className='menu-list quad no-wrap' onClick={ (e) => e.stopPropagation() }>
|
<div className='menu-list quad no-wrap' onClick={ (e) => e.stopPropagation() }>
|
||||||
{this._getShipsMenu()}
|
{this._getShipsMenu()}
|
||||||
|
|||||||
Reference in New Issue
Block a user