Merge pull request #798 from Brighter-Applications/develop

Develop
This commit is contained in:
Alex Williams
2024-11-23 21:49:46 +00:00
committed by GitHub
6 changed files with 72 additions and 23 deletions

View File

@@ -57,6 +57,7 @@ export default class ModificationsMenu extends TranslatedComponent {
this.modValDidChange = false; // used to determine if component update was caused by change in modification value.
this._handleModChange = this._handleModChange.bind(this);
// console.log(props.m.blueprint)
this.state = {
blueprintMenuOpened: !(props.m.blueprint && props.m.blueprint.name),
specialMenuOpened: false
@@ -421,15 +422,31 @@ export default class ModificationsMenu extends TranslatedComponent {
let haveBlueprint = false;
let blueprintTt;
let blueprintCv;
let bprintSearchName;
// If the fdname is Weapon_Overcharged, we need to check if it's an MC
if (m.blueprint && m.blueprint.fdname) {
// Set the bprintSearchName value to the fdname of the blueprint for this module
bprintSearchName = m.blueprint.fdname;
if (m.blueprint.fdname === 'Weapon_Overcharged') {
// If the module is a MultiCannon, we need to fix the blueprint search name, else it will find the Laser Weapon_Overcharged Blueprint and not the MC Weapon_Overcharged Blueprint
if (m.symbol.match(/MultiCannon/i)) {
// console.log(Modifications.modules[m.grp].blueprints['MC_Overcharged']);
// console.log(m.blueprint.fdname);
bprintSearchName = 'MC_Overcharged';
}
}
}
// TODO: Fix this to actually find the correct blueprint.
if (!m.blueprint || !m.blueprint.name || !m.blueprint.fdname || !Modifications.modules[m.grp].blueprints || !Modifications.modules[m.grp].blueprints[m.blueprint.fdname]) {
if (!m.blueprint || !m.blueprint.name || !m.blueprint.fdname || !Modifications.modules[m.grp].blueprints || !Modifications.modules[m.grp].blueprints[bprintSearchName]) {
this.props.ship.clearModuleBlueprint(m);
this.props.ship.clearModuleSpecial(m);
}
if (m.blueprint && m.blueprint.name && Modifications.modules[m.grp].blueprints[m.blueprint.fdname].grades[m.blueprint.grade]) {
if (m.blueprint && m.blueprint.name && Modifications.modules[m.grp].blueprints[bprintSearchName].grades[m.blueprint.grade]) {
blueprintLabel = translate(m.blueprint.name) + ' ' + translate('grade') + ' ' + m.blueprint.grade;
haveBlueprint = true;
blueprintTt = blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], Modifications.modules[m.grp].blueprints[m.blueprint.fdname].grades[m.blueprint.grade].engineers, m.grp);
// console.log(haveBlueprint);
blueprintTt = blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], Modifications.modules[m.grp].blueprints[bprintSearchName].grades[m.blueprint.grade].engineers, m.grp);
blueprintCv = getPercent(m);
}

View File

@@ -125,15 +125,32 @@ export default class PowerManagement extends TranslatedComponent {
retractedElem = <td className='ptr disabled upp' colSpan='2' onClick={toggleEnabled}>{translate('disabled')}</td>;
}
// If this is a Guardian Shield Reinforcement Package or Guardian Hull Reinforcement Package, or Guardian Module Reinforcement Package, it cannot change priority
console.log(slot);
let priorityField;
if (m.symbol) {
if (m.symbol.match(/GuardianShield/i) || m.symbol.match(/GuardianHull/i) || m.symbol.match(/GuardianModule/i)) {
priorityField = <td>1</td>;
} else {
priorityField = <td>
<span className='flip ptr btn' onClick={this._priority.bind(this, slot, -1)}>&#9658;</span>
{' ' + (slot.priority + 1) + ' '}
<span className='ptr btn' onClick={this._priority.bind(this, slot, 1)}>&#9658;</span>
</td>;
}
}
else {
priorityField = <td>
<span className='flip ptr btn' onClick={this._priority.bind(this, slot, -1)}>&#9658;</span>
{' ' + (slot.priority + 1) + ' '}
<span className='ptr btn' onClick={this._priority.bind(this, slot, 1)}>&#9658;</span>
</td>;
}
powerRows.push(<tr key={i} className={cn('highlight', { disabled: !slot.enabled })}>
<td className='ptr' style={{ width: '1em' }} onClick={toggleEnabled}>{m.class + m.rating}</td>
<td className='ptr le shorten cap' onClick={toggleEnabled}>{slotName(translate, slot)}</td>
<td className='ptr' onClick={toggleEnabled}><u>{translate(slot.type)}</u></td>
<td>
<span className='flip ptr btn' onClick={this._priority.bind(this, slot, -1)}>&#9658;</span>
{' ' + (slot.priority + 1) + ' '}
<span className='ptr btn' onClick={this._priority.bind(this, slot, 1)}>&#9658;</span>
</td>
{priorityField}
<td className='ri ptr' style={{ width: '3.25em' }} onClick={toggleEnabled}>{pwr(m.getPowerUsage())}</td>
<td className='ri ptr' style={{ width: '3em' }} onClick={toggleEnabled}><u>{pct(m.getPowerUsage() / ship.powerAvailable)}</u></td>
{retractedElem}

View File

@@ -133,10 +133,10 @@ export default class StandardSlot extends TranslatedComponent {
<div className={'r'}>{formats.round(mass)}{units.T}</div>
<div/>
<div className={'cb'}>
{ m.getMinMass() ? <div className='l'>{translate('minimum mass')}: {formats.int(m.getMinMass())}{units.T}</div> : null }
{ m.getOptMass() ? <div className='l'>{translate('optimal mass')}: {formats.int(m.getOptMass())}{units.T}</div> : null }
{ m.getMaxMass() ? <div className='l'>{translate('max mass')}: {formats.int(m.getMaxMass())}{units.T}</div> : null }
{ m.getOptMul() ? <div className='l'>{translate('optimal multiplier')}: {formats.rPct(m.getOptMul())}</div> : null }
{ m.getMinMass() ? <div className='l'>{translate('minmass')}: {formats.int(m.getMinMass())}{units.T}</div> : null }
{ m.getOptMass() ? <div className='l'>{translate('optmass')}: {formats.int(m.getOptMass())}{units.T}</div> : null }
{ m.getMaxMass() ? <div className='l'>{translate('maxmass')}: {formats.int(m.getMaxMass())}{units.T}</div> : null }
{ m.getOptMul() ? <div className='l'>{translate('optmul')}: {formats.rPct(m.getOptMul())}</div> : null }
{ m.getRange() ? <div className='l'>{translate('range', m.grp)}: {formats.f2(m.getRange())}{units.km}</div> : null }
{ m.time ? <div className='l'>{translate('time')}: {formats.time(m.time)}</div> : null }
{ m.getThermalEfficiency() ? <div className='l'>{translate('efficiency')}: {formats.f2(m.getThermalEfficiency())}</div> : null }

View File

@@ -276,8 +276,10 @@
"thermres": "Thermal resistance",
"wepcap": "Weapons capacity",
"weprate": "Weapons recharge rate",
"minmass": "Minimum mass",
"minmass_sg": "Minimum hull mass",
"optmass_sg": "Optimal hull mass",
"maxmass": "Maximum mass",
"maxmass_sg": "Maximum hull mass",
"minmul_sg": "Minimum strength",
"optmul_sg": "Optimal strength",

View File

@@ -307,10 +307,22 @@ export function isChangeValueBeneficial(feature, value) {
* @returns {Object} The matching blueprint
*/
export function getBlueprint(name, module) {
// Special case for multi-cannons. Conflicting 'Weapon_Overcharged' Blueprints exist due to FD's naming conventions. If this blueprint is for a multi-cannon, we need to use the correct blueprint.
if (name === 'weapon_overcharged') {
if (module.symbol.match(/MultiCannon/i)) {
name = 'mc_overcharged';
}
}
else if (name === 'Weapon_Overcharged') {
if (module.symbol.match(/MultiCannon/i)) {
name = 'MC_Overcharged';
}
}
// Start with a copy of the blueprint
const findMod = val => Object.keys(Modifications.blueprints).find(elem => elem.toString().toLowerCase().search(val.toString().toLowerCase().replace(/(OutfittingFieldType_|persecond)/igm, '')) >= 0);
const found = Modifications.blueprints[findMod(name)];
if (!found || !found.fdname) {
console.error('Blueprint not found:', name);
return {};
}
const blueprint = JSON.parse(JSON.stringify(found));

View File

@@ -349,6 +349,7 @@ function _addModifications(module, modifiers, quality, blueprint, grade, special
// Add the blueprint definition, grade and special
if (blueprint) {
module.blueprint = getBlueprint(blueprint, module);
if (grade) {
module.blueprint.grade = Number(grade);
}