forked from cmmcleod/coriolis
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
4,212 additions
and
2,077 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ nginx.pid | |
.idea | ||
/bin | ||
env | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -320,7 +320,6 @@ | |
"shieldExplRes": 0.5, | ||
"shieldKinRes": 0.4, | ||
"shieldThermRes": -0.2, | ||
"timeToDrain": 7.04, | ||
"crew": 3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import React from 'react'; | ||
import TranslatedComponent from './TranslatedComponent'; | ||
import { Ships } from 'coriolis-data/dist'; | ||
import { nameComparator } from '../utils/SlotFunctions'; | ||
import { Pip } from './SvgIcons'; | ||
import LineChart from '../components/LineChart'; | ||
import Slider from '../components/Slider'; | ||
import * as ModuleUtils from '../shipyard/ModuleUtils'; | ||
import Module from '../shipyard/Module'; | ||
|
||
/** | ||
* Boost displays a boost button that toggles bosot | ||
* Requires an onChange() function of the form onChange(boost) which is triggered whenever the boost changes. | ||
*/ | ||
export default class Boost extends TranslatedComponent { | ||
static propTypes = { | ||
marker: React.PropTypes.string.isRequired, | ||
ship: React.PropTypes.object.isRequired, | ||
boost: React.PropTypes.bool.isRequired, | ||
onChange: React.PropTypes.func.isRequired | ||
}; | ||
|
||
/** | ||
* Constructor | ||
* @param {Object} props React Component properties | ||
* @param {Object} context React Component context | ||
*/ | ||
constructor(props, context) { | ||
super(props); | ||
const { ship, boost } = props; | ||
|
||
this._keyDown = this._keyDown.bind(this); | ||
this._toggleBoost = this._toggleBoost.bind(this); | ||
} | ||
|
||
/** | ||
* Add listeners after mounting | ||
*/ | ||
componentDidMount() { | ||
document.addEventListener('keydown', this._keyDown); | ||
} | ||
|
||
/** | ||
* Remove listeners before unmounting | ||
*/ | ||
componentWillUnmount() { | ||
document.removeEventListener('keydown', this._keyDown); | ||
} | ||
|
||
/** | ||
* Handle Key Down | ||
* @param {Event} e Keyboard Event | ||
*/ | ||
_keyDown(e) { | ||
if (e.ctrlKey || e.metaKey) { // CTRL/CMD | ||
switch (e.keyCode) { | ||
case 66: // b == boost | ||
if (this.props.ship.canBoost()) { | ||
e.preventDefault(); | ||
this._toggleBoost(); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Toggle the boost feature | ||
*/ | ||
_toggleBoost() { | ||
this.props.onChange(!this.props.boost); | ||
} | ||
|
||
/** | ||
* Render boost | ||
* @return {React.Component} contents | ||
*/ | ||
render() { | ||
const { formats, translate, units } = this.context.language; | ||
const { ship, boost } = this.props; | ||
|
||
// TODO disable if ship cannot boost | ||
return ( | ||
<span id='boost'> | ||
<button id='boost' className={boost ? 'selected' : null} onClick={this._toggleBoost}>{translate('boost')}</button> | ||
</span> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from 'react'; | ||
import TranslatedComponent from './TranslatedComponent'; | ||
import { Ships } from 'coriolis-data/dist'; | ||
import Slider from '../components/Slider'; | ||
|
||
/** | ||
* Cargo slider | ||
* Requires an onChange() function of the form onChange(cargo), providing the cargo in tonnes, which is triggered on cargo level change | ||
*/ | ||
export default class Cargo extends TranslatedComponent { | ||
static propTypes = { | ||
cargo: React.PropTypes.number.isRequired, | ||
cargoCapacity: React.PropTypes.number.isRequired, | ||
onChange: React.PropTypes.func.isRequired | ||
}; | ||
|
||
/** | ||
* Constructor | ||
* @param {Object} props React Component properties | ||
* @param {Object} context React Component context | ||
*/ | ||
constructor(props, context) { | ||
super(props); | ||
|
||
this._cargoChange = this._cargoChange.bind(this); | ||
} | ||
|
||
/** | ||
* Update cargo level | ||
* @param {number} cargoLevel percentage level from 0 to 1 | ||
*/ | ||
_cargoChange(cargoLevel) { | ||
const { cargo, cargoCapacity } = this.props; | ||
if (cargoCapacity > 0) { | ||
// We round the cargo to whole number of tonnes | ||
const newCargo = Math.round(cargoLevel * cargoCapacity); | ||
if (newCargo != cargo) { | ||
this.props.onChange(newCargo); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Render cargo slider | ||
* @return {React.Component} contents | ||
*/ | ||
render() { | ||
const { language, onWindowResize, sizeRatio, tooltip, termtip } = this.context; | ||
const { formats, translate, units } = language; | ||
const { cargo, cargoCapacity } = this.props; | ||
|
||
return ( | ||
<span> | ||
<h3>{translate('cargo carried')}: {formats.int(cargo)}{units.T}</h3> | ||
<table style={{ width: '100%', lineHeight: '1em', backgroundColor: 'transparent' }}> | ||
<tbody > | ||
<tr> | ||
<td> | ||
<Slider | ||
axis={true} | ||
onChange={this._cargoChange} | ||
axisUnit={translate('T')} | ||
percent={cargo / cargoCapacity} | ||
max={cargoCapacity} | ||
scale={sizeRatio} | ||
onResize={onWindowResize} | ||
/> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</span> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.