Ensure module ordering is consistent

This commit is contained in:
Cmdr McDonald
2016-12-12 10:28:54 +00:00
parent a6a10df39c
commit 5426b55637
4 changed files with 34 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
* Add movement summary to outfitting page
* Add standard internal class sizes to shipyard page
* Fix issue when importing Viper Mk IV
* Ensure ordering of all types of modules (standard, internal, utilities) is consistent
#2.2.5
* Calculate rate of fire for multi-burst weapons

View File

@@ -93,8 +93,10 @@ export default class AvailableModulesMenu extends TranslatedComponent {
let prevClass = null, prevRating = null;
let elems = [];
for (let i = 0; i < modules.length; i++) {
let m = modules[i];
const sortedModules = modules.sort(this._moduleOrder);
for (let i = 0; i < sortedModules.length; i++) {
let m = sortedModules[i];
let mount = null;
let disabled = m.maxmass && (mass + (m.mass ? m.mass : 0)) > m.maxmass;
let active = mountedModule && mountedModule.id === m.id;
@@ -126,7 +128,7 @@ export default class AvailableModulesMenu extends TranslatedComponent {
case 'T': mount = <MountTurret className={'lg'}/>; break;
}
if (i > 0 && modules.length > 3 && m.class != prevClass && (m.rating != prevRating || m.mount) && m.grp != 'pa') {
if (i > 0 && sortedModules.length > 3 && m.class != prevClass && (m.rating != prevRating || m.mount) && m.grp != 'pa') {
elems.push(<br key={'b' + m.grp + i} />);
}
@@ -201,6 +203,32 @@ export default class AvailableModulesMenu extends TranslatedComponent {
this.context.tooltip();
}
_moduleOrder(a, b) {
// Named modules go last
if (!a.name && b.name) {
return -1;
}
if (a.name && !b.name) {
return 1;
}
// Class ordered from highest (8) to lowest (1)
if (a.class < b.class) {
return 1;
}
if (a.class > b.class) {
return -1;
// Rating ordered from lowest (E) to highest (A)
}
if (a.rating < b.rating) {
return 1;
}
if (a.rating > b.rating) {
return -1;
}
// Do not attempt to order by name at this point, as that mucks up the order of armour
return 0;
}
/**
* Scroll to mounted (if it exists) module group on mount
*/

View File

@@ -46,7 +46,7 @@ export default class MovementSummary extends TranslatedComponent {
<td>2</td>
<td>3</td>
<td>4</td>
<td>4B</td>
<td onMouseOver={termtip.bind(null, '4b')} onMouseOut={tooltip.bind(null, null)}>4B</td>
</tr>
<tr>
<td className='ri'>{translate('speed')} ({units['m/s']})</td>

View File

@@ -109,6 +109,7 @@ export const terms = {
'recovery': 'Recovery',
'recharge': 'Recharge',
'engine pips': 'Engine Pips',
'4b': '4 pips and boost',
'speed': 'Speed',
'pitch': 'Pitch',
'roll': 'Roll',