From e246b737b284934a6ebfcce725450118872cad11 Mon Sep 17 00:00:00 2001 From: ExitCode Date: Sat, 21 Apr 2018 23:53:02 +0200 Subject: [PATCH 1/6] reused random functionality as it worked better on percentage rolls between min/max --- src/app/utils/BlueprintFunctions.js | 35 +++++++++++------------------ 1 file changed, 13 insertions(+), 22 deletions(-) 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 From 9e6f86b963cba8e6b522827c170f2253ddcacb21 Mon Sep 17 00:00:00 2001 From: ExitCode Date: Sun, 22 Apr 2018 00:28:04 +0200 Subject: [PATCH 2/6] (optional) changed roll presets to 0-50-100 --- src/app/components/ModificationsMenu.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index 85083a2a..65e13f40 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -33,7 +33,7 @@ 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 = { @@ -195,11 +195,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 +227,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; @@ -275,8 +275,8 @@ export default class ModificationsMenu extends TranslatedComponent { { showRolls ? { translate('roll') }: + { translate('0%') } { translate('50%') } - { translate('75%') } { translate('100%') } { translate('random') } : null } From 926f19a936e71d388961fb27cc612116d5781a09 Mon Sep 17 00:00:00 2001 From: ExitCode Date: Sun, 22 Apr 2018 00:59:44 +0200 Subject: [PATCH 3/6] added default init 100% on bp selection as the new system makes it obvious to reach 100% --- src/app/components/ModificationsMenu.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index 65e13f40..d1d5af81 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -136,6 +136,7 @@ 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.props.onChange(); From 66afb61494a87ab6c5553acc232465f582c7e764 Mon Sep 17 00:00:00 2001 From: ExitCode Date: Sun, 22 Apr 2018 03:41:21 +0200 Subject: [PATCH 4/6] added new style for inline menu buttons --- src/less/buttons.less | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) 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; From 24a229d818f38f2fe3a18479ad37d9d8c723e4eb Mon Sep 17 00:00:00 2001 From: ExitCode Date: Sun, 22 Apr 2018 03:43:57 +0200 Subject: [PATCH 5/6] Implemented workflow on bp assignment; applied some styles --- src/app/components/ModificationsMenu.jsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index d1d5af81..9171da8b 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -37,7 +37,7 @@ export default class ModificationsMenu extends TranslatedComponent { 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; @@ -138,7 +141,7 @@ export default class ModificationsMenu extends TranslatedComponent { ship.setModuleBlueprint(m, blueprint); setPercent(ship, m, 100); - this.setState({ blueprintMenuOpened: false }); + this.setState({ blueprintMenuOpened: false, specialMenuOpened: true }); this.props.onChange(); } @@ -264,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 ? From 4442930a82af459db29ad0e6762f29d57d886469 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Sun, 22 Apr 2018 12:26:06 +1000 Subject: [PATCH 6/6] bump --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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"