diff --git a/package-lock.json b/package-lock.json index ac819bfc..03b02f22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "coriolis_shipyard", - "version": "2.9.4", + "version": "2.9.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c15ae150..b2d09374 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coriolis_shipyard", - "version": "2.9.6", + "version": "2.9.7", "repository": { "type": "git", "url": "https://github.com/EDCD/coriolis" diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index 85083a2a..9171da8b 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -33,11 +33,11 @@ export default class ModificationsMenu extends TranslatedComponent { this._rollFifty = this._rollFifty.bind(this); this._rollRandom = this._rollRandom.bind(this); this._rollBest = this._rollBest.bind(this); - this._rollSevenFive = this._rollSevenFive.bind(this); + this._rollWorst = this._rollWorst.bind(this); this._reset = this._reset.bind(this); this.state = { - blueprintMenuOpened: false, + blueprintMenuOpened: !(props.m.blueprint && props.m.blueprint.name), specialMenuOpened: false }; } @@ -91,10 +91,13 @@ export default class ModificationsMenu extends TranslatedComponent { const specialsId = m.missile && Modifications.modules[m.grp]['specials_' + m.missile] ? 'specials_' + m.missile : 'specials'; if (Modifications.modules[m.grp][specialsId] && Modifications.modules[m.grp][specialsId].length > 0) { const close = this._specialSelected.bind(this, null); - specials.push(
{translate('PHRASE_NO_SPECIAL')}
); + specials.push(
{translate('PHRASE_NO_SPECIAL')}
); for (const specialName of Modifications.modules[m.grp][specialsId]) { + const classes = cn('button-inline-menu', { + active: m.blueprint && m.blueprint.special && m.blueprint.special.edname == specialName + }); const close = this._specialSelected.bind(this, specialName); - specials.push(
{translate(Modifications.specials[specialName].name)}
); + specials.push(
{translate(Modifications.specials[specialName].name)}
); } } return specials; @@ -136,8 +139,9 @@ export default class ModificationsMenu extends TranslatedComponent { const blueprint = getBlueprint(fdname, m); blueprint.grade = grade; ship.setModuleBlueprint(m, blueprint); + setPercent(ship, m, 100); - this.setState({ blueprintMenuOpened: false }); + this.setState({ blueprintMenuOpened: false, specialMenuOpened: true }); this.props.onChange(); } @@ -195,11 +199,11 @@ export default class ModificationsMenu extends TranslatedComponent { } /** - * Provide an '75%' roll within the information we have + * Provide a 'worst' roll within the information we have */ - _rollSevenFive() { + _rollWorst() { const { m, ship } = this.props; - setPercent(ship, m, 75); + setPercent(ship, m, 0); this.props.onChange(); } @@ -227,7 +231,7 @@ export default class ModificationsMenu extends TranslatedComponent { const _toggleBlueprintsMenu = this._toggleBlueprintsMenu; const _toggleSpecialsMenu = this._toggleSpecialsMenu; const _rollFull = this._rollBest; - const _rollSevenFive = this._rollSevenFive; + const _rollWorst = this._rollWorst; const _rollFifty = this._rollFifty; const _rollRandom = this._rollRandom; const _reset = this._reset; @@ -263,11 +267,11 @@ export default class ModificationsMenu extends TranslatedComponent { onClick={(e) => e.stopPropagation() } onContextMenu={stopCtxPropagation} > - { showBlueprintsMenu ? '' : haveBlueprint ? -
{blueprintLabel}
: -
{translate('PHRASE_SELECT_BLUEPRINT')}
} + { showBlueprintsMenu | showSpecialsMenu ? '' : haveBlueprint ? +
{blueprintLabel}
: +
{translate('PHRASE_SELECT_BLUEPRINT')}
} { showBlueprintsMenu ? this._renderBlueprints(this.props, this.context) : null } - { showSpecial ?
{specialLabel}
: null } + { showSpecial & !showSpecialsMenu ?
{specialLabel}
: null } { showSpecialsMenu ? specials : null } { showRolls || showReset ? @@ -275,8 +279,8 @@ export default class ModificationsMenu extends TranslatedComponent { { showRolls ? + - : null } diff --git a/src/app/utils/BlueprintFunctions.js b/src/app/utils/BlueprintFunctions.js index 878c2af6..29a342f7 100644 --- a/src/app/utils/BlueprintFunctions.js +++ b/src/app/utils/BlueprintFunctions.js @@ -253,34 +253,15 @@ export function getBlueprint(name, module) { } /** - * Provide 'worst' primary modifications + * Provide 'percent' primary modifications * @param {Object} ship The ship for which to perform the modifications * @param {Object} m The module for which to perform the modifications * @param {Number} percent The percent to set values to of full. */ export function setPercent(ship, m, percent) { ship.clearModifications(m); - const features = m.blueprint.grades[m.blueprint.grade].features; - for (const featureName in features) { - const value = features[featureName][1]; - const featureIsBeneficial = isBeneficial(featureName, features[featureName]); - if (featureIsBeneficial === true) { - _setValue(ship, m, featureName, (percent / 100) * value); - } else { - _setValue(ship, m, featureName, value); - } - } -} - -/** - * Provide 'random' primary modifications - * @param {Object} ship The ship for which to perform the modifications - * @param {Object} m The module for which to perform the modifications - */ -export function setRandom(ship, m) { - ship.clearModifications(m); - // Pick a single value for our randomness - const mult = Math.random(); + // Pick given value as multiplier + const mult = percent / 100; const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { let value; @@ -304,6 +285,16 @@ export function setRandom(ship, m) { } } +/** + * Provide 'random' primary modifications + * @param {Object} ship The ship for which to perform the modifications + * @param {Object} m The module for which to perform the modifications + */ +export function setRandom(ship, m) { + // Pick a single value for our randomness + setPercent(ship, m, Math.random() * 100); +} + /** * Set a modification feature value * @param {Object} ship The ship for which to perform the modifications diff --git a/src/less/buttons.less b/src/less/buttons.less index 62ccb87d..9a52a550 100755 --- a/src/less/buttons.less +++ b/src/less/buttons.less @@ -31,6 +31,50 @@ button { } } +.button-inline-menu { + white-space: nowrap; + line-height: 1.5em; + text-align: center; + margin: 0.5em 0; + padding-left: 5px; + border-top: 1px solid @primary-disabled; + border-bottom: 1px solid @primary-disabled; + overflow: hidden; + text-overflow: ellipsis; + background: @primary-bg; + + &.warning { + border-color: @warning-disabled; + color: @warning-disabled; + stroke: @warning-disabled; + + .no-touch &:hover { + border-color: @warning; + color: @warning; + stroke: @warning; + } + } + + &.disabled, &.disabled:hover { + cursor: not-allowed; + border-color: @disabled; + color: @disabled; + stroke: @disabled; + } + + &.active { + border-color: @secondary; + color: @secondary; + stroke: @secondary; + } + + &:hover { + border-color: @primary; + color: @primary; + stroke: @primary; + } + } + .button-lbl { margin-left: 0.5em;
{ translate('roll') }: { translate('0%') } { translate('50%') } { translate('75%') } { translate('100%') } { translate('random') }