Merge pull request #730 from Sid127/edomh-v1

Initial EDOMH integration
This commit is contained in:
Felix Linker
2022-12-27 13:19:05 +01:00
committed by GitHub
8 changed files with 90 additions and 17 deletions

View File

@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
import TranslatedComponent from './TranslatedComponent';
import request from 'superagent';
import Persist from '../stores/Persist';
const zlib = require('zlib');
const base64url = require('base64url');
/**
* Permalink modal
@@ -56,7 +58,6 @@ export default class ModalShoppingList extends TranslatedComponent {
continue;
}
if (module.m.blueprint.special) {
console.log(module.m.blueprint.special);
blueprints.push({ uuid: module.m.blueprint.special.uuid, number: 1 });
}
for (const g in module.m.blueprint.grades) {
@@ -146,6 +147,64 @@ export default class ModalShoppingList extends TranslatedComponent {
}
}
/**
* Send all blueprints to EDOMH. This is a modified copy of registerBPs because this.state.blueprints was empty when I tried to modify sendToEDEng and I couldn't figure out why
* @param {Event} event React event
*/
sendToEDOMH(event) {
event.preventDefault();
const ship = this.props.ship;
let blueprints = [];
//create the json
for (const module of ship.costList) {
if (module.type === 'SHIP') {
continue;
}
if (module.m && module.m.blueprint) {
if (!module.m.blueprint.grade || !module.m.blueprint.grades) {
continue;
}
if (module.m.blueprint.special) {
blueprints.push({
"item": module.m.symbol,
"blueprint": module.m.blueprint.special.edname
});
}
for (const g in module.m.blueprint.grades) {
if (!module.m.blueprint.grades.hasOwnProperty(g)) {
continue;
}
if (g < module.m.blueprint.grade) {
continue;
}
blueprints.push({
"item": module.m.symbol,
"blueprint": module.m.blueprint.fdname,
"grade": module.m.blueprint.grade,
"highestGradePercentage":1.0
});
}
}
}
//create JSON to encode
let baseJson = {
"version":1,
"name":ship.name, // TO-DO: Import build name and put that here correctly
"items": blueprints
}
let JSONString = JSON.stringify(baseJson)
let deflated = zlib.deflateSync(JSONString)
//actually encode
let link = base64url.encode(deflated)
link = "edomh://coriolis/?" + link;
window.open(link, "_self")
}
/**
* Convert mats object to string
*/
@@ -241,6 +300,7 @@ export default class ModalShoppingList extends TranslatedComponent {
const compatible = this.checkBrowserIsCompatible();
this.cmdrChangeHandler = this.cmdrChangeHandler.bind(this);
this.sendToEDEng = this.sendToEDEng.bind(this);
this.sendToEDOMH = this.sendToEDOMH.bind(this);
return <div className='modal' onClick={ (e) => e.stopPropagation() }>
<h2>{translate('PHRASE_SHOPPING_MATS')}</h2>
<label>{translate('Grade 1 rolls ')}</label>
@@ -269,6 +329,7 @@ export default class ModalShoppingList extends TranslatedComponent {
<p hidden={!this.state.failed} id={'failed'} className={'l'}>{translate('PHRASE_FAIL_EDENGINEER')}</p>
<p hidden={compatible} id={'browserbad'} className={'l'}>{translate('PHRASE_FIREFOX_EDENGINEER')}</p>
<button className={'l cb dismiss cap'} disabled={!!this.state.failed || !compatible} onClick={this.sendToEDEng}>{translate('Send to EDEngineer')}</button>
<button style={{marginTop: 5}} className={'l cb dismiss cap'} disabled={!!this.state.failed} onClick={this.sendToEDOMH}>{translate('Send to EDOMH')}</button>
<button className={'r dismiss cap'} onClick={this.context.hideModal}>{translate('close')}</button>
</div>;
}

View File

@@ -398,6 +398,7 @@
"No modded components.": "没有改装的部件",
"Sending...": "发送中...",
"Send to EDEngineer": "发送至EDEngineer",
"Send to EDOMH": "发送至EDOMH",
"PHASE_UPLOAD_ORBIS": "上传到orbis.zone测试阶段",
"orbis username": "orbis.zone的Email或用户名",
"orbis password": "orbis.zone的密码",

View File

@@ -159,6 +159,7 @@
"tp": "Torpedo Pylon",
"ul": "Burst Laser",
"Send To EDEngineer": "Send To EDEngineer",
"Send To EDOMH": "Send To EDOMH",
"ws": "Frame Shift Wake Scanner",
"rpl": "Repair Limpet Controller",
"rcpl": "Recon Limpet Controller",

View File

@@ -159,6 +159,7 @@
"tp": "어뢰관",
"ul": "버스트 레이저",
"Send To EDEngineer": "EDEngineer에 전송",
"Send To EDOMH": "EDOMH에 전송",
"ws": "프레임 시프트 흔적 스캐너",
"rpl": "수리용 림펫 컨트롤러",
"rcpl": "정찰용 림펫 컨트롤러",

View File

@@ -403,6 +403,7 @@
"No modded components.": "Nenhum componente modificado.",
"Sending...": "Enviando...",
"Send to EDEngineer": "Enviar para EDEngineer",
"Send to EDOMH": "Enviar para EDOMH",
"PHRASE_UPLOAD_ORBIS": "Enviar para orbis.zone (Período trial.)",
"orbis username": "Usuário/email para orbis.zone",
"orbis password": "Senha para orbis.zone",

View File

@@ -159,6 +159,7 @@
"tp": "Торпедная установка",
"ul": "Пульсирующий лазер",
"Send To EDEngineer": "Отправить в EDEngineer",
"Send To EDOMH": "Отправить в EDOMH",
"ws": "Сканер следа FSD",
"rpl": "Контроллер дронов-ремонтников",
"rcpl": "Контроллер дронов-разведчиков",