mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
Sort mods in modifications menu by editable first
This commit is contained in:
@@ -15,6 +15,10 @@ import {
|
|||||||
specialToolTip
|
specialToolTip
|
||||||
} from '../utils/BlueprintFunctions';
|
} from '../utils/BlueprintFunctions';
|
||||||
|
|
||||||
|
const MODIFICATIONS_COMPARATOR = (mod1, mod2) => {
|
||||||
|
return mod1.props.name.localeCompare(mod2.props.name);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifications menu
|
* Modifications menu
|
||||||
*/
|
*/
|
||||||
@@ -205,17 +209,20 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
*/
|
*/
|
||||||
_renderModifications(props) {
|
_renderModifications(props) {
|
||||||
const { m, onChange, ship } = props;
|
const { m, onChange, ship } = props;
|
||||||
|
const modifiableModifications = [];
|
||||||
const modifications = [];
|
const modifications = [];
|
||||||
for (const modName of Modifications.modules[m.grp].modifications) {
|
for (const modName of Modifications.modules[m.grp].modifications) {
|
||||||
if (!Modifications.modifications[modName].hidden) {
|
if (!Modifications.modifications[modName].hidden) {
|
||||||
const key = modName + (m.getModValue(modName) / 100 || 0);
|
const key = modName + (m.getModValue(modName) / 100 || 0);
|
||||||
|
const editable = modName !== 'fallofffromrange' &&
|
||||||
|
m.blueprint.grades[m.blueprint.grade].features[modName];
|
||||||
this.lastNeId = modName;
|
this.lastNeId = modName;
|
||||||
modifications.push(<Modification key={ key } ship={ ship } m={ m }
|
(editable ? modifiableModifications : modifications).push(
|
||||||
value={ m.getModValue(modName) / 100 || 0 } modItems={ this.modItems }
|
<Modification key={ key } ship={ ship } m={ m }
|
||||||
onChange={ onChange } onKeyDown={ this._keyDown }
|
value={m.getModValue(modName) / 100 || 0} modItems={this.modItems}
|
||||||
editable={modName !== 'fallofffromrange' &&
|
onChange={onChange} onKeyDown={this._keyDown} name={modName}
|
||||||
m.blueprint.grades[m.blueprint.grade].features[modName]
|
editable={editable} handleModChange = {this._handleModChange} />
|
||||||
} name={ modName } handleModChange = {this._handleModChange} />);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,10 +237,9 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.modifications = modifications.sort(
|
modifiableModifications.sort(MODIFICATIONS_COMPARATOR);
|
||||||
(mod1, mod2) => mod1.props.name.localeCompare(mod2.props.name)
|
modifications.sort(MODIFICATIONS_COMPARATOR);
|
||||||
);
|
return modifiableModifications.concat(modifications);
|
||||||
return this.modifications;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user