From 0ea25692d3ccc0f5727fc7666614aff731971864 Mon Sep 17 00:00:00 2001 From: William Blythe Date: Wed, 7 Nov 2018 13:08:35 +1100 Subject: [PATCH 01/19] work on sw --- src/app/Coriolis.jsx | 50 +++++++++++++++++++++++--------------------- src/sw.js | 1 + 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/app/Coriolis.jsx b/src/app/Coriolis.jsx index 37a3abda..8041ccff 100644 --- a/src/app/Coriolis.jsx +++ b/src/app/Coriolis.jsx @@ -348,30 +348,32 @@ export default class Coriolis extends React.Component { // *Don't* register service worker file in, e.g., a scripts/ sub-directory! // See https://github.com/slightlyoff/ServiceWorker/issues/468 const self = this; - register('/service-worker.js', { - ready (registration) { - console.log('Service worker is active.') - }, - registered (registration) { - console.log('Service worker has been registered.') - }, - cached (registration) { - console.log('Content has been cached for offline use.') - }, - updatefound (registration) { - console.log('New content is downloading.') - }, - updated (registration) { - self.setState({ appCacheUpdate: true }); - console.log('New content is available; please refresh.') - }, - offline () { - console.log('No internet connection found. App is running in offline mode.') - }, - error (error) { - console.error('Error during service worker registration:', error) - } - }); + if (process.env.NODE_ENV === 'production') { + register('/service-worker.js', { + ready (registration) { + console.log('Service worker is active.') + }, + registered (registration) { + console.log('Service worker has been registered.') + }, + cached (registration) { + console.log('Content has been cached for offline use.') + }, + updatefound (registration) { + console.log('New content is downloading.') + }, + updated (registration) { + self.setState({ appCacheUpdate: true }); + console.log('New content is available; please refresh.') + }, + offline () { + console.log('No internet connection found. App is running in offline mode.') + }, + error (error) { + console.error('Error during service worker registration:', error) + } + }); + } } window.onerror = this._onError.bind(this); window.addEventListener('resize', () => this.emitter.emit('windowResize')); diff --git a/src/sw.js b/src/sw.js index 2299d54e..7ba222e4 100644 --- a/src/sw.js +++ b/src/sw.js @@ -2,6 +2,7 @@ console.log('Hello from sw.js'); if (workbox) { console.log('Yay! Workbox is loaded 🎉'); + workbox.precaching.precacheAndRoute(self.__precacheManifest); workbox.routing.registerRoute( new RegExp('https://fonts.(?:googleapis|gstatic).com/(.*)'), workbox.strategies.cacheFirst({ From 6c932f96a6f03526ffb5c980ef457e9a0c0d4932 Mon Sep 17 00:00:00 2001 From: William Blythe Date: Fri, 9 Nov 2018 11:28:37 +1100 Subject: [PATCH 02/19] add fill weapons for AX weps --- src/app/components/HardpointSlotSection.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/components/HardpointSlotSection.jsx b/src/app/components/HardpointSlotSection.jsx index bc3b0c99..68ec3c15 100644 --- a/src/app/components/HardpointSlotSection.jsx +++ b/src/app/components/HardpointSlotSection.jsx @@ -153,6 +153,15 @@ export default class HardpointSlotSection extends SlotSection { +
{translate('ggc')}
+ +
{translate('rfl')}
+ ; } From ae247c4812227c00427b98459b097e17d7d6fd3b Mon Sep 17 00:00:00 2001 From: willyb321 Date: Sat, 10 Nov 2018 09:39:22 +1100 Subject: [PATCH 03/19] support beta flag --- src/app/pages/ShipyardPage.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/pages/ShipyardPage.jsx b/src/app/pages/ShipyardPage.jsx index e09d0e5b..7ead18ae 100644 --- a/src/app/pages/ShipyardPage.jsx +++ b/src/app/pages/ShipyardPage.jsx @@ -61,6 +61,7 @@ function shipSummary(shipId, shipData) { id: shipId, hpCount: 0, intCount: 0, + beta: shipData.beta, maxCargo: 0, maxPassengers: 0, hp: [0, 0, 0, 0, 0], // Utility, Small, Medium, Large, Huge @@ -318,7 +319,7 @@ export default class ShipyardPage extends Page { onMouseEnter={noTouch && this._highlightShip.bind(this, s.id)} > - {s.name} + {s.name} {s.beta === true ? '(Beta)' : null} ); From dd7a133caaa45c2e39246aaa0c56428ffe32d5ae Mon Sep 17 00:00:00 2001 From: willyb321 Date: Sun, 11 Nov 2018 01:31:30 +1100 Subject: [PATCH 04/19] add search bar initial why am i awake its like 2am --- package.json | 1 + src/app/components/AvailableModulesMenu.jsx | 92 ++++++++++++++++----- src/less/select.less | 9 ++ 3 files changed, 81 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index b81809bb..28dbe455 100644 --- a/package.json +++ b/package.json @@ -135,6 +135,7 @@ "react": "^15.5.4", "react-dom": "^15.5.4", "react-extras": "^0.7.1", + "react-fuzzy": "^0.5.2", "react-ga": "^2.5.3", "react-number-editor": "Athanasius/react-number-editor.git#miggy", "recharts": "^1.2.0", diff --git a/src/app/components/AvailableModulesMenu.jsx b/src/app/components/AvailableModulesMenu.jsx index cddafb14..abc7b4c7 100644 --- a/src/app/components/AvailableModulesMenu.jsx +++ b/src/app/components/AvailableModulesMenu.jsx @@ -5,6 +5,7 @@ import TranslatedComponent from './TranslatedComponent'; import { stopCtxPropagation } from '../utils/UtilityFunctions'; import cn from 'classnames'; import { MountFixed, MountGimballed, MountTurret } from './SvgIcons'; +import FuzzySearch from 'react-fuzzy'; const PRESS_THRESHOLD = 500; // mouse/touch down threshold @@ -39,7 +40,7 @@ const GRPCAT = { 'mc': 'projectiles', 'axmc': 'experimental', 'fc': 'projectiles', - 'rfl': 'experimental', + 'rfl': 'experimental', 'pa': 'projectiles', 'rg': 'projectiles', 'mr': 'ordnance', @@ -133,6 +134,7 @@ export default class AvailableModulesMenu extends TranslatedComponent { constructor(props, context) { super(props); this._hideDiff = this._hideDiff.bind(this); + this._showSearch = this._showSearch.bind(this); this.state = this._initState(props, context); this.slotItems = [];// Array to hold
  • refs. } @@ -159,7 +161,7 @@ export default class AvailableModulesMenu extends TranslatedComponent { onSelect(m); } ); - + let fuzzy = []; if (modules instanceof Array) { list = buildGroup(modules[0].grp, modules); } else { @@ -167,9 +169,11 @@ export default class AvailableModulesMenu extends TranslatedComponent { // At present time slots with grouped options (Hardpoints and Internal) can be empty if (m) { let emptyId = 'empty'; - if(this.firstSlotId == null) this.firstSlotId = emptyId; + if (this.firstSlotId == null) this.firstSlotId = emptyId; let keyDown = this._keyDown.bind(this, onSelect); - list.push(
    this.slotItems[emptyId] = slotItem} >{translate('empty')}
    ); + list.push(
    this.slotItems[emptyId] = slotItem}>{translate('empty')}
    ); } // Need to regroup the modules by our own categorisation @@ -197,7 +201,8 @@ export default class AvailableModulesMenu extends TranslatedComponent { if (categories.length === 1) { // Show category header instead of group header if (m && grp == m.grp) { - list.push(
    this.groupElem = elem} key={category} className={'select-category upp'}>{translate(category)}
    ); + list.push(
    this.groupElem = elem} key={category} + className={'select-category upp'}>{translate(category)}
    ); } else { list.push(
    {translate(category)}
    ); } @@ -208,19 +213,23 @@ export default class AvailableModulesMenu extends TranslatedComponent { categoryHeader = true; } if (m && grp == m.grp) { - list.push(
    this.groupElem = elem} key={grp} className={'select-group cap'}>{translate(grp)}
    ); + list.push(
    this.groupElem = elem} key={grp} + className={'select-group cap'}>{translate(grp)}
    ); } else { list.push(
    {translate(grp)}
    ); } } list.push(buildGroup(grp, modules[grp])); + for (const i of modules[grp]) { + fuzzy.push({ grp, m: i, name: `${i.class}${i.rating} ${translate(grp)} ${i.mount ? i.mount : ''}` }); + } } } } } } let trackingFocus = false; - return { list, currentGroup, trackingFocus }; + return { list, currentGroup, fuzzy, trackingFocus }; } /** @@ -242,9 +251,11 @@ export default class AvailableModulesMenu extends TranslatedComponent { const sortedModules = modules.sort(this._moduleOrder); - // Calculate the number of items per class. Used so we don't have long lists with only a few items in each row - const tmp = sortedModules.map((v, i) => v['class']).reduce((count, cls) => { count[cls] = ++count[cls] || 1; return count; }, {}); + const tmp = sortedModules.map((v, i) => v['class']).reduce((count, cls) => { + count[cls] = ++count[cls] || 1; + return count; + }, {}); const itemsPerClass = Math.max.apply(null, Object.keys(tmp).map(key => tmp[key])); let itemsOnThisRow = 0; @@ -297,22 +308,29 @@ export default class AvailableModulesMenu extends TranslatedComponent { }; } - switch(m.mount) { - case 'F': mount = ; break; - case 'G': mount = ; break; - case 'T': mount = ; break; + switch (m.mount) { + case 'F': + mount = ; + break; + case 'G': + mount = ; + break; + case 'T': + mount = ; + break; } if (m.name && m.name === prevName) { // elems.push(
    ); itemsOnThisRow = 0; } if (itemsOnThisRow == 6 || i > 0 && sortedModules.length > 3 && itemsPerClass > 2 && m.class != prevClass && (m.rating != prevRating || m.mount)) { - elems.push(
    ); + elems.push(
    ); itemsOnThisRow = 0; } let tbIdx = (classes.indexOf('disabled') < 0) ? 0 : undefined; elems.push( -
  • this.slotItems[m.id] = slotItem}> +
  • this.slotItems[m.id] = slotItem}> {mount} {(mount ? ' ' : '') + m.class + m.rating + (m.missile ? '/' + m.missile : '') + (m.name ? ' ' + translate(m.name) : '')}
  • @@ -340,6 +358,36 @@ export default class AvailableModulesMenu extends TranslatedComponent { } } + /** + * Generate tooltip content for the difference between the + * mounted module and the hovered modules + */ + _showSearch() { + return ( + this.props.onSelect.bind(null, e.m)()} + resultsTemplate={(props, state, styles, clickHandler) => { + return state.results.map((val, i) => { + return ( +
    clickHandler(i)} + > + {val.name} +
    + ); + }); + }} + /> + ); + } + /** * Mouse over diff handler * @param {Function} showDiff diff tooltip callback @@ -405,7 +453,7 @@ export default class AvailableModulesMenu extends TranslatedComponent { * @param {Function} select Select module callback * @param {SytheticEvent} event Event */ - _keyUp(select,event) { + _keyUp(select, event) { // nothing here yet } @@ -475,12 +523,13 @@ export default class AvailableModulesMenu extends TranslatedComponent { this.slotItems[this.firstSlotId].focus(); } } + /** * Handle focus if the component updates * */ componentWillUnmount() { - if(this.props.slotDiv) { + if (this.props.slotDiv) { this.props.slotDiv.focus(); } } @@ -501,11 +550,12 @@ export default class AvailableModulesMenu extends TranslatedComponent { render() { return (
    this.node = node} - className={cn('select', this.props.className)} - onScroll={this._hideDiff} - onClick={(e) => e.stopPropagation() } - onContextMenu={stopCtxPropagation} + className={cn('select', this.props.className)} + onScroll={this._hideDiff} + onClick={(e) => e.stopPropagation()} + onContextMenu={stopCtxPropagation} > + {this._showSearch()} {this.state.list}
    ); diff --git a/src/less/select.less b/src/less/select.less index 012baa18..f84f6acb 100755 --- a/src/less/select.less +++ b/src/less/select.less @@ -22,6 +22,15 @@ select { } } +.react-fuzzy-search > * { + padding: 0 !important; + color: @primary; + & > input { + border: 1px solid @primary !important; + color: @primary-bg; + } +} + .cmdr-select { border: 1px solid @primary; padding: 0.5em 0.5em; From 3d3f9e44b56c2b75de87868af87903c361723026 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Sun, 11 Nov 2018 01:57:06 +1100 Subject: [PATCH 05/19] add damage per shot --- src/app/components/HardpointSlot.jsx | 102 +++++++++++++++++++-------- src/app/i18n/en.json | 1 + 2 files changed, 72 insertions(+), 31 deletions(-) diff --git a/src/app/components/HardpointSlot.jsx b/src/app/components/HardpointSlot.jsx index f7678f0c..4626aef0 100644 --- a/src/app/components/HardpointSlot.jsx +++ b/src/app/components/HardpointSlot.jsx @@ -2,12 +2,21 @@ import React from 'react'; import cn from 'classnames'; import Slot from './Slot'; import Persist from '../stores/Persist'; -import { DamageAbsolute, DamageKinetic, DamageThermal, DamageExplosive, MountFixed, MountGimballed, MountTurret, ListModifications, Modified } from './SvgIcons'; +import { + DamageAbsolute, + DamageKinetic, + DamageThermal, + DamageExplosive, + MountFixed, + MountGimballed, + MountTurret, + ListModifications, + Modified +} from './SvgIcons'; import { Modifications } from 'coriolis-data/dist'; import { stopCtxPropagation } from '../utils/UtilityFunctions'; import { blueprintTooltip } from '../utils/BlueprintFunctions'; - /** * Hardpoint / Utility Slot */ @@ -27,7 +36,7 @@ export default class HardpointSlot extends Slot { * @return {string} Label */ _getMaxClassLabel(translate) { - return translate(['U','S','M','L','H'][this.props.maxClass]); + return translate(['U', 'S', 'M', 'L', 'H'][this.props.maxClass]); } /** @@ -66,42 +75,73 @@ export default class HardpointSlot extends Slot { return
    - {m.mount && m.mount == 'F' ? : ''} - {m.mount && m.mount == 'G' ? : ''} - {m.mount && m.mount == 'T' ? : ''} - {m.getDamageDist() && m.getDamageDist().K ? : ''} - {m.getDamageDist() && m.getDamageDist().T ? : ''} - {m.getDamageDist() && m.getDamageDist().E ? : ''} - {m.getDamageDist() && m.getDamageDist().A ? : ''} - {classRating} {translate(m.name || m.grp)}{ m.mods && Object.keys(m.mods).length > 0 ? : null } + {m.mount && m.mount == 'F' ? : ''} + {m.mount && m.mount == 'G' ? : ''} + {m.mount && m.mount == 'T' ? : ''} + {m.getDamageDist() && m.getDamageDist().K ? : ''} + {m.getDamageDist() && m.getDamageDist().T ? : ''} + {m.getDamageDist() && m.getDamageDist().E ? : ''} + {m.getDamageDist() && m.getDamageDist().A ? : ''} + {classRating} {translate(m.name || m.grp)}{m.mods && Object.keys(m.mods).length > 0 ? : null}
    {formats.round(m.getMass())}{u.T}
    - { m.getDps() ?
    {translate('DPS')}: {formats.round1(m.getDps())} { m.getClip() ? ({formats.round1(m.getSDps()) }) : null }
    : null } - { m.getEps() ?
    {translate('EPS')}: {formats.round1(m.getEps())}{u.MW} { m.getClip() ? ({formats.round1((m.getClip() * m.getEps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload())) }{u.MW}) : null }
    : null } - { m.getHps() ?
    {translate('HPS')}: {formats.round1(m.getHps())} { m.getClip() ? ({formats.round1((m.getClip() * m.getHps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload())) }) : null }
    : null } - { m.getDps() && m.getEps() ?
    {translate('DPE')}: {formats.f1(m.getDps() / m.getEps())}
    : null } - { m.getRoF() ?
    {translate('ROF')}: {formats.f1(m.getRoF())}{u.ps}
    : null } - { m.getRange() ?
    {translate('range', m.grp)} {formats.f1(m.getRange() / 1000)}{u.km}
    : null } - { m.getScanTime() ?
    {translate('scantime')} {formats.f1(m.getScanTime())}{u.s}
    : null } - { m.getFalloff() ?
    {translate('falloff')} {formats.round(m.getFalloff() / 1000)}{u.km}
    : null } - { m.getShieldBoost() ?
    +{formats.pct1(m.getShieldBoost())}
    : null } - { m.getAmmo() ?
    {translate('ammunition')}: {formats.int(m.getClip())}/{formats.int(m.getAmmo())}
    : null } - { m.getReload() ?
    {translate('reload')}: {formats.round(m.getReload())}{u.s}
    : null } - { m.getShotSpeed() ?
    {translate('shotspeed')}: {formats.int(m.getShotSpeed())}{u.mps}
    : null } - { m.getPiercing() ?
    {translate('piercing')}: {formats.int(m.getPiercing())}
    : null } - { m.getJitter() ?
    {translate('jitter')}: {formats.f2(m.getJitter())}°
    : null } - { showModuleResistances && m.getExplosiveResistance() ?
    {translate('explres')}: {formats.pct(m.getExplosiveResistance())}
    : null } - { showModuleResistances && m.getKineticResistance() ?
    {translate('kinres')}: {formats.pct(m.getKineticResistance())}
    : null } - { showModuleResistances && m.getThermalResistance() ?
    {translate('thermres')}: {formats.pct(m.getThermalResistance())}
    : null } - { m.getIntegrity() ?
    {translate('integrity')}: {formats.int(m.getIntegrity())}
    : null } - { m && validMods.length > 0 ?
    this.modButton = modButton }>
    : null } + {m.getDps() ?
    {translate('DPS')}: {formats.round1(m.getDps())} {m.getClip() ? + ({formats.round1(m.getSDps())}) : null}
    : null} + {m.getDamage() ?
    {translate('shotdmg')}: {formats.round1(m.getDamage())}
    : null} + {m.getEps() ?
    {translate('EPS')}: {formats.round1(m.getEps())}{u.MW} {m.getClip() ? + ({formats.round1((m.getClip() * m.getEps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()))}{u.MW}) : null}
    : null} + {m.getHps() ?
    {translate('HPS')}: {formats.round1(m.getHps())} {m.getClip() ? + ({formats.round1((m.getClip() * m.getHps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()))}) : null}
    : null} + {m.getDps() && m.getEps() ?
    {translate('DPE')}: {formats.f1(m.getDps() / m.getEps())}
    : null} + {m.getRoF() ?
    {translate('ROF')}: {formats.f1(m.getRoF())}{u.ps}
    : null} + {m.getRange() ?
    {translate('range', m.grp)} {formats.f1(m.getRange() / 1000)}{u.km}
    : null} + {m.getScanTime() ?
    {translate('scantime')} {formats.f1(m.getScanTime())}{u.s}
    : null} + {m.getFalloff() ?
    {translate('falloff')} {formats.round(m.getFalloff() / 1000)}{u.km}
    : null} + {m.getShieldBoost() ?
    +{formats.pct1(m.getShieldBoost())}
    : null} + {m.getAmmo() ?
    {translate('ammunition')}: {formats.int(m.getClip())}/{formats.int(m.getAmmo())}
    : null} + {m.getReload() ?
    {translate('reload')}: {formats.round(m.getReload())}{u.s}
    : null} + {m.getShotSpeed() ?
    {translate('shotspeed')}: {formats.int(m.getShotSpeed())}{u.mps}
    : null} + {m.getPiercing() ?
    {translate('piercing')}: {formats.int(m.getPiercing())}
    : null} + {m.getJitter() ?
    {translate('jitter')}: {formats.f2(m.getJitter())}°
    : null} + {showModuleResistances && m.getExplosiveResistance() ?
    {translate('explres')}: {formats.pct(m.getExplosiveResistance())}
    : null} + {showModuleResistances && m.getKineticResistance() ?
    {translate('kinres')}: {formats.pct(m.getKineticResistance())}
    : null} + {showModuleResistances && m.getThermalResistance() ?
    {translate('thermres')}: {formats.pct(m.getThermalResistance())}
    : null} + {m.getIntegrity() ?
    {translate('integrity')}: {formats.int(m.getIntegrity())}
    : null} + {m && validMods.length > 0 ?
    this.modButton = modButton}> + +
    : null}
    ; } else { - return
    {translate('empty')}
    ; + return
    {translate('empty')}
    ; } } diff --git a/src/app/i18n/en.json b/src/app/i18n/en.json index 2c669361..3ffaf009 100644 --- a/src/app/i18n/en.json +++ b/src/app/i18n/en.json @@ -240,6 +240,7 @@ "shieldboost": "Shield boost", "shieldreinforcement": "Shield reinforcement", "shotspeed": "Shot speed", + "shotdmg": "Damage Per Shot", "spinup": "Spin up time", "syscap": "Systems capacity", "sysrate": "Systems recharge rate", From 4e891f382c7b3221b9ca96c00f1b9297efd6e7cb Mon Sep 17 00:00:00 2001 From: willyb321 Date: Tue, 13 Nov 2018 06:25:17 +1100 Subject: [PATCH 06/19] prep for import --- src/app/utils/CompanionApiUtils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/utils/CompanionApiUtils.js b/src/app/utils/CompanionApiUtils.js index b35669b7..7058d49b 100644 --- a/src/app/utils/CompanionApiUtils.js +++ b/src/app/utils/CompanionApiUtils.js @@ -31,6 +31,7 @@ export const SHIP_FD_NAME_TO_CORIOLIS_NAME = { 'Independant_Trader': 'keelback', 'Krait_MkII': 'krait_mkii', 'Mamba': 'mamba', + 'Krait_Light': 'krait_phantom', 'Orca': 'orca', 'Python': 'python', 'SideWinder': 'sidewinder', From 71b90eb6f4ce282a111f9f729df4afa9c93f4a7d Mon Sep 17 00:00:00 2001 From: William Blythe Date: Tue, 13 Nov 2018 09:11:43 +1100 Subject: [PATCH 07/19] maybe an actually good service worker for once --- src/sw.js | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/sw.js b/src/sw.js index 7ba222e4..5eb5d3e0 100644 --- a/src/sw.js +++ b/src/sw.js @@ -3,6 +3,14 @@ console.log('Hello from sw.js'); if (workbox) { console.log('Yay! Workbox is loaded 🎉'); workbox.precaching.precacheAndRoute(self.__precacheManifest); + + workbox.routing.registerNavigationRoute('/index.html'); + + workbox.routing.registerRoute( + new RegExp('/(.*?)'), + workbox.strategies.staleWhileRevalidate() + ); + workbox.routing.registerRoute( new RegExp('https://fonts.(?:googleapis|gstatic).com/(.*)'), workbox.strategies.cacheFirst({ @@ -41,23 +49,3 @@ self.addEventListener('message', event => { break; } }); -const OFFLINE_URL = '/'; -self.addEventListener('fetch', function(event) { - console.log('Handling fetch event for', event.request.url); - - event.respondWith( - caches.match(event.request).then(function(response) { - if (response) { - return response; - } - - return fetch(event.request) - .then(function(response) { - return response; - }) - .catch(function(error) { - return caches.match(OFFLINE_URL); - }); - }) - ); -}); From eda61a8e0668c192f5324507ae9f2f680216eaf2 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Sat, 17 Nov 2018 09:26:57 +1100 Subject: [PATCH 08/19] in theory fix guardian pds Closes #339 --- src/app/shipyard/ModuleUtils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/shipyard/ModuleUtils.js b/src/app/shipyard/ModuleUtils.js index e913fce4..276de3c1 100755 --- a/src/app/shipyard/ModuleUtils.js +++ b/src/app/shipyard/ModuleUtils.js @@ -63,7 +63,10 @@ export function standard(type, id) { if (!isNaN(type)) { type = StandardArray[type]; } - let s = Modules.standard[type].find(e => e.id == id || (e.class == id.charAt(0) && e.rating == id.charAt(1))); + let s = Modules.standard[type].find(e => e.id === id); + if (!s) { + s = Modules.standard[type].find(e => (e.class == id.charAt(0) && e.rating == id.charAt(1))); + } if (s) { s = new Module({ template: s }); } From 8a2d27290aedb0567de17db395304affd7af25d5 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Mon, 19 Nov 2018 06:58:12 +1100 Subject: [PATCH 09/19] add some logging to assist DWE2 people (temp) --- src/app/shipyard/Ship.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index b6db1b53..3a4dc70b 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -1501,8 +1501,8 @@ export default class Ship { } else { buffer.writeInt32LE(slotMod.value, curpos); } - // const modification = _.find(Modifications.modifications, function(o) { return o.id === slotMod.id; }); - // console.log('ENCODE Slot ' + i + ': ' + modification.name + ' = ' + slotMod.value); + const modification = _.find(Modifications.modifications, function(o) { return o.id === slotMod.id; }); + console.log('ENCODE Slot ' + i + ': ' + modification.name + ' = ' + slotMod.value); curpos += 4; } buffer.writeInt8(MODIFICATION_ID_DONE, curpos++); @@ -1556,7 +1556,7 @@ export default class Ship { blueprint.special = _.find(Modifications.specials, function(o) { return o.id === modificationValue; }); } else { const modification = _.find(Modifications.modifications, function(o) { return o.id === modificationId; }); - // console.log('DECODE Slot ' + slot + ': ' + modification.name + ' = ' + modificationValue); + console.log('DECODE Slot ' + slot + ': ' + modification.name + ' = ' + modificationValue); modifications[modification.name] = modificationValue; } modificationId = buffer.readInt8(curpos++); From cc4ad6d1327db83167a3a9beb3bb75eb2817ba55 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Mon, 19 Nov 2018 06:58:53 +1100 Subject: [PATCH 10/19] and a bit moree --- src/app/shipyard/Ship.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 3a4dc70b..6231e224 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -1514,6 +1514,7 @@ export default class Ship { } this.serialized.modifications = zlib.gzipSync(buffer).toString('base64'); + console.log(this.serialized.modifications) } else { this.serialized.modifications = null; } From 2295dccd8255c1f60f7453db0a47b8deb850428b Mon Sep 17 00:00:00 2001 From: willyb321 Date: Mon, 19 Nov 2018 07:10:05 +1100 Subject: [PATCH 11/19] re-enable bugsnag --- webpack.config.prod.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webpack.config.prod.js b/webpack.config.prod.js index 6d95e652..0db1e2ae 100644 --- a/webpack.config.prod.js +++ b/webpack.config.prod.js @@ -48,10 +48,10 @@ module.exports = { disable: false, allChunks: true }), - // new BugsnagSourceMapUploaderPlugin({ - // apiKey: 'ba9fae819372850fb660755341fa6ef5', - // appVersion: `${pkgJson.version}-${buildDate.toISOString()}` - // }), + new BugsnagSourceMapUploaderPlugin({ + apiKey: 'ba9fae819372850fb660755341fa6ef5', + appVersion: `${pkgJson.version}-${buildDate.toISOString()}` + }), new InjectManifest({ swSrc: './src/sw.js', importWorkboxFrom: 'cdn', From 7c587c29aa6788cdb0a050de8d50feb5d532b4d5 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Mon, 19 Nov 2018 07:12:36 +1100 Subject: [PATCH 12/19] add build reporter plugin --- webpack.config.prod.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webpack.config.prod.js b/webpack.config.prod.js index 0db1e2ae..55fb4b63 100644 --- a/webpack.config.prod.js +++ b/webpack.config.prod.js @@ -4,7 +4,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const { InjectManifest } = require('workbox-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); -const { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins'); +const { BugsnagSourceMapUploaderPlugin, BugsnagBuildReporterPlugin } = require('webpack-bugsnag-plugins'); const pkgJson = require('./package'); const buildDate = new Date(); @@ -48,8 +48,13 @@ module.exports = { disable: false, allChunks: true }), + new BugsnagBuildReporterPlugin({ + apiKey: 'ba9fae819372850fb660755341fa6ef5', + appVersion: `${pkgJson.version}-${buildDate.toISOString()}` + }, { /* opts */ }), new BugsnagSourceMapUploaderPlugin({ apiKey: 'ba9fae819372850fb660755341fa6ef5', + overwrite: true, appVersion: `${pkgJson.version}-${buildDate.toISOString()}` }), new InjectManifest({ From 77401a3b3fdf0276f21e525cdbf7747724c28fae Mon Sep 17 00:00:00 2001 From: William Blythe Date: Mon, 19 Nov 2018 09:21:18 +1100 Subject: [PATCH 13/19] get ready for dw2 site --- .docker/docker-compose.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 5a25f19f..fb097ff5 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -29,6 +29,20 @@ services: - "traefik.basic.port=80" - "traefik.basic.protocol=http" + coriolis_dw2: + image: edcd/coriolis:dw2 + restart: always + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + networks: + - web + labels: + - "traefik.docker.network=web" + - "traefik.enable=true" + - "traefik.basic.frontend.rule=Host:dw2.coriolis.io" + - "traefik.basic.port=80" + - "traefik.basic.protocol=http" + networks: web: external: true From fbf59219d0f30982a6562291a777423c3243bec4 Mon Sep 17 00:00:00 2001 From: felixlinker Date: Sat, 17 Nov 2018 01:56:58 +0000 Subject: [PATCH 14/19] Apply diminishing returns for hull resistance modding to all modules --- src/app/shipyard/Module.js | 33 ++++++++------------------------- src/app/shipyard/Ship.js | 5 +++++ 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index d03202a4..83d5de58 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -41,6 +41,7 @@ export default class Module { * @return {object} The value of the modification. If it is a numeric value then it is returned as an integer value scaled so that 1.23% == 123 */ getModValue(name, raw) { + let baseVal = this[name]; let result = this.mods && this.mods[name] ? this.mods[name] : null; if ((!raw) && this.blueprint && this.blueprint.special) { @@ -51,13 +52,8 @@ export default class Module { const modification = Modifications.modifications[name]; const multiplier = modification.type === 'percentage' ? 10000 : 100; if (name === 'explres' || name === 'kinres' || name === 'thermres' || name === 'causres') { - // Resistance modifications in itself are additive, however their - // special effects are multiplicative. They affect the overall result - // by (special effect resistance) * (damage mult after modification), - // i. e. we need to apply the special effect as a multiplier to the - // overall result and then calculate the difference. - let baseMult = this[name] ? 1 - this[name] : 1; - result = (baseMult - (baseMult - result / multiplier) * (1 - modifierActions[name] / 100)) * multiplier; + // Apply resistance modding mechanisms to special effects subsequently + result = result + modifierActions[name] * (1 - (this[name] + result / multiplier)) * 100; } else if (modification.method === 'additive') { result = result + modifierActions[name] * 100; } else if (modification.method === 'overwrite') { @@ -75,15 +71,6 @@ export default class Module { } } - // Resistance modding for hull reinforcement packages has additional - // diminishing returns implemented. The mod value gets lowered by - // the amount of base resistance the hrp has. - if (!isNaN(result) && this.grp === 'hr' && - (name === 'kinres' || name === 'thermres' || name === 'explres')) { - let baseRes = this[name]; - result = result * (1 - baseRes); - } - // Sanitise the resultant value to 4dp equivalent return isNaN(result) ? result : Math.round(result); } @@ -108,11 +95,11 @@ export default class Module { // This special effect modifies the value being set, so we need to revert it prior to storing the value const modification = Modifications.modifications[name]; if (name === 'explres' || name === 'kinres' || name === 'thermres' || name === 'causres') { - // Resistance modifications in itself are additive but their - // experimentals are applied multiplicatively therefor we must handle - // them differently here (cf. documentation in getModValue). - let baseMult = (this[name] ? 1 - this[name] : 1); - value = ((baseMult - value / 10000) / (1 - modifierActions[name] / 100) - baseMult) * -10000; + let res = (this[name] ? this[name] : 0) + value / 10000; + let experimental = modifierActions[name] / 100; + value = (experimental - res) / (experimental - 1) - this[name]; + value *= 10000; + // value = ((baseMult - value / 10000) / (1 - modifierActions[name] / 100) - baseMult) * -10000; } else if (modification.method === 'additive') { value = value - modifierActions[name]; } else if (modification.method === 'overwrite') { @@ -177,10 +164,6 @@ export default class Module { baseValue = 0; } modValue = value - baseValue; - if (this.grp === 'hr' && - (name === 'kinres' || name === 'thermres' || name === 'explres')) { - modValue = modValue / (1 - baseValue); - } } else if (name === 'shieldboost' || name === 'hullboost') { modValue = (1 + value) / (1 + baseValue) - 1; } else { // multiplicative diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index b6db1b53..f79cdf1e 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -505,6 +505,11 @@ export default class Ship { if (isAbsolute) { m.setPretty(name, value, sentfromui); } else { + // Resistance modifiers scale with the base value + if (name == 'kinres' || name == 'thermres' || name == 'causres' || name == 'explres') { + let baseValue = m.get(name, false); + value = (1 - baseValue) * value; + } m.setModValue(name, value, sentfromui); } From 934de01803fd72ad08440d2ad540b5c0c4587ce7 Mon Sep 17 00:00:00 2001 From: Willyb321 Date: Wed, 21 Nov 2018 08:50:53 +1100 Subject: [PATCH 15/19] add announcements to actual page --- src/app/Coriolis.jsx | 2 ++ src/app/components/Announcement.jsx | 2 +- src/less/app.less | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/Coriolis.jsx b/src/app/Coriolis.jsx index 8041ccff..0595b41c 100644 --- a/src/app/Coriolis.jsx +++ b/src/app/Coriolis.jsx @@ -6,6 +6,7 @@ import { EventEmitter } from 'fbemitter'; import { getLanguage } from './i18n/Language'; import Persist from './stores/Persist'; +import Announcement from './components/Announcement'; import Header from './components/Header'; import Tooltip from './components/Tooltip'; import ModalExport from './components/ModalExport'; @@ -395,6 +396,7 @@ export default class Coriolis extends React.Component { return
    +
    {this.state.announcements.map(a => )}
    {this.state.error ? this.state.error : this.state.page ? React.createElement(this.state.page, { currentMenu }) : } {this.state.modal} diff --git a/src/app/components/Announcement.jsx b/src/app/components/Announcement.jsx index 76a3bdb5..1c2df735 100644 --- a/src/app/components/Announcement.jsx +++ b/src/app/components/Announcement.jsx @@ -25,7 +25,7 @@ export default class Announcement extends React.Component { * @return {React.Component} A href element */ render() { - return

    {this.props.text}

    ; + return
    {this.props.text}
    ; } } diff --git a/src/less/app.less b/src/less/app.less index 69c72d71..566a9825 100755 --- a/src/less/app.less +++ b/src/less/app.less @@ -171,3 +171,16 @@ footer { text-align: right; } } + +.announcement-container { + display: flex; + align-items: center; + padding-top: 10px; + justify-content: center; + flex-flow: row wrap; +} + +.announcement { + border: 1px @secondary solid; + padding: 10px; +} From b3be0bd63980b83f00ccdc03d02db2530ddc4a4f Mon Sep 17 00:00:00 2001 From: Willyb321 Date: Wed, 21 Nov 2018 09:00:50 +1100 Subject: [PATCH 16/19] remove logs --- src/app/shipyard/Ship.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 6fd05249..92aab6e7 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -1507,7 +1507,7 @@ export default class Ship { buffer.writeInt32LE(slotMod.value, curpos); } const modification = _.find(Modifications.modifications, function(o) { return o.id === slotMod.id; }); - console.log('ENCODE Slot ' + i + ': ' + modification.name + ' = ' + slotMod.value); + // console.log('ENCODE Slot ' + i + ': ' + modification.name + ' = ' + slotMod.value); curpos += 4; } buffer.writeInt8(MODIFICATION_ID_DONE, curpos++); @@ -1519,7 +1519,7 @@ export default class Ship { } this.serialized.modifications = zlib.gzipSync(buffer).toString('base64'); - console.log(this.serialized.modifications) + // console.log(this.serialized.modifications) } else { this.serialized.modifications = null; } @@ -1562,7 +1562,7 @@ export default class Ship { blueprint.special = _.find(Modifications.specials, function(o) { return o.id === modificationValue; }); } else { const modification = _.find(Modifications.modifications, function(o) { return o.id === modificationId; }); - console.log('DECODE Slot ' + slot + ': ' + modification.name + ' = ' + modificationValue); + // console.log('DECODE Slot ' + slot + ': ' + modification.name + ' = ' + modificationValue); modifications[modification.name] = modificationValue; } modificationId = buffer.readInt8(curpos++); From ec0d05e0815a9c64d718cbba38d8a8e8625f77c4 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Thu, 22 Nov 2018 07:31:45 +1100 Subject: [PATCH 17/19] add beta resting heat --- src/app/components/ShipSummaryTable.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/components/ShipSummaryTable.jsx b/src/app/components/ShipSummaryTable.jsx index 134d8e41..176fc12e 100644 --- a/src/app/components/ShipSummaryTable.jsx +++ b/src/app/components/ShipSummaryTable.jsx @@ -52,6 +52,7 @@ export default class ShipSummaryTable extends TranslatedComponent { const boostTooltip = canBoost ? 'TT_SUMMARY_BOOST' : canThrust ? 'TT_SUMMARY_BOOST_NONFUNCTIONAL' : 'TT_SUMMARY_SPEED_NONFUNCTIONAL'; const sgMetrics = Calc.shieldMetrics(ship, pips.sys); const shipBoost = canBoost ? Calc.calcBoost(ship) : 'No Boost'; + const restingHeat = Math.sqrt(((ship.standard[0].m.pgen * ship.standard[0].m.eff) / ship.heatCapacity) / 0.2); const armourMetrics = Calc.armourMetrics(ship); let shieldColour = 'blue'; if (shieldGenerator && shieldGenerator.m.grp === 'psg') { @@ -85,6 +86,7 @@ export default class ShipSummaryTable extends TranslatedComponent { {translate('crew')} {translate('MLF')} {translate('boost time')} + {translate('resting heat (Beta)')} {translate('max')} @@ -122,6 +124,7 @@ export default class ShipSummaryTable extends TranslatedComponent { {ship.crew} {ship.masslock} {shipBoost !== 'No Boost' ? formats.time(shipBoost) : 'No Boost'} + {formats.pct(restingHeat)} From 222173b38834485ac52a7dd39d3d9f892a1ee9e7 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Sun, 25 Nov 2018 07:54:16 +1100 Subject: [PATCH 18/19] add category select to orbis modal --- src/app/components/ModalOrbis.jsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/app/components/ModalOrbis.jsx b/src/app/components/ModalOrbis.jsx index 56896fd4..9580fdfb 100644 --- a/src/app/components/ModalOrbis.jsx +++ b/src/app/components/ModalOrbis.jsx @@ -23,8 +23,10 @@ export default class ModalOrbis extends TranslatedComponent { this.state = { orbisCreds: Persist.getOrbisCreds(), orbisUrl: '...', + ship: this.props.ship, authenticatedStatus: 'Checking...' }; + this.orbisCategory = this.orbisCategory.bind(this); } /** @@ -88,6 +90,17 @@ export default class ModalOrbis extends TranslatedComponent { }); } + /** + * Handler for changing category + * @param {SyntheticEvent} e React Event + */ + orbisCategory(e) { + let ship = this.state.ship; + let cat = e.target.value; + ship.category = cat; + this.setState({ship}); + } + /** * Render the modal * @return {React.Component} Modal Content @@ -106,6 +119,17 @@ export default class ModalOrbis extends TranslatedComponent {

    Log in / signup to Orbis

    +

    Category

    + +

    {translate('Orbis link')}

    e.target.select() }/>

    From bbba048129769a083f9d0bcaf961dc0669559986 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Fri, 30 Nov 2018 06:56:01 +1100 Subject: [PATCH 19/19] update to bugsnag 5 --- src/index.ejs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/index.ejs b/src/index.ejs index 7efd299c..784b8414 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -59,9 +59,7 @@ - - +