mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
Slightly friendlier modifications
This commit is contained in:
@@ -34,14 +34,15 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
_updateValue(value) {
|
_updateValue(value) {
|
||||||
let scaledValue = Math.floor(Number(value) * 100);
|
let scaledValue = Math.floor(Number(value) * 100);
|
||||||
// Limit to +1000% / -100%
|
// Limit to +1000% / -100%
|
||||||
if (scaledValue > 10000) {
|
if (scaledValue > 100000) {
|
||||||
scaledValue = 10000;
|
scaledValue = 100000;
|
||||||
value = 1000;
|
value = 1000;
|
||||||
}
|
}
|
||||||
if (scaledValue < -1000) {
|
if (scaledValue < -10000) {
|
||||||
scaledValue = -1000;
|
scaledValue = -10000;
|
||||||
value = -100;
|
value = -100;
|
||||||
}
|
}
|
||||||
|
|
||||||
let m = this.props.m;
|
let m = this.props.m;
|
||||||
let name = this.props.name;
|
let name = this.props.name;
|
||||||
let ship = this.props.ship;
|
let ship = this.props.ship;
|
||||||
@@ -62,7 +63,7 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
return (
|
return (
|
||||||
<div className={'cb'} key={name}>
|
<div className={'cb'} key={name}>
|
||||||
<div className={'cb'}>{translate(name)}{name === 'jitter' ? ' (°)' : ' (%)'}</div>
|
<div className={'cb'}>{translate(name)}{name === 'jitter' ? ' (°)' : ' (%)'}</div>
|
||||||
<NumberEditor className={'cb'} style={{ width: '100%', textAlign: 'center' }} step={0.01} stepModifier={1} decimals={2} value={this.state.value} onValueChange={this._updateValue.bind(this)} />
|
<NumberEditor className={'cb'} style={{ width: '90%', textAlign: 'center' }} step={0.01} stepModifier={1} decimals={2} value={this.state.value} onValueChange={this._updateValue.bind(this)} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -402,6 +402,11 @@ export default class Ship {
|
|||||||
* @param {Number} value The new value of the modification. The value of the modification is scaled to provide two decimal places of precision in an integer. For example 1.23% is stored as 123
|
* @param {Number} value The new value of the modification. The value of the modification is scaled to provide two decimal places of precision in an integer. For example 1.23% is stored as 123
|
||||||
*/
|
*/
|
||||||
setModification(m, name, value) {
|
setModification(m, name, value) {
|
||||||
|
if (isNaN(value)) {
|
||||||
|
// Value passed is invalid; reset it to 0
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle special cases
|
// Handle special cases
|
||||||
if (name === 'pgen') {
|
if (name === 'pgen') {
|
||||||
// Power generation
|
// Power generation
|
||||||
|
|||||||
Reference in New Issue
Block a user