-
Notifications
You must be signed in to change notification settings - Fork 85
Add possibility to export SLEF builds #827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| _copySLEF() { | ||
| navigator.clipboard.writeText(this.state.exportSLEF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This button won't be shown if the browser doesn't support the clipboard object. In this case the text will automatically be selected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the copy icon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed consoles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
| group.push({ | ||
| m: null, | ||
| incCost: true, | ||
| slotIndex: slotCounter.get(currentSlotType).length, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds the slotIndex so we can better control the name of it without needing a state to start the index over
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, Utility Mounts are a special case of Hardpoints that have maxClass as 0. To export as a journal we need to put TinyHardpoint1 in the field name, but if the utility mount is the 6th index from the hardpoints, we need to first reset the index
| incCost: true, | ||
| maxClass: slot, | ||
| // Add helper if it's a hardpoint | ||
| ...(slotType === 'hardpoints' ? {isUtilityMount: isUtility} : {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for future proofing, just in case someone else needs to check if it's a utility mount
| FSD: "FrameShiftDrive", | ||
| Thrusters: "MainEngines", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I found both of these in the official journals, so I added them here to cover all the bases
| ...ship.hardpoints.reduce(hardpointsToSLEF, []), | ||
| ...ship.internal.reduce(optionalInternalToSLEF, []), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be maps, but they'd add the undefined values (which would be removed by the stringify) so, reduce already filters those out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for exporting ship builds in the SLEF format alongside the existing Coriolis format.
- Introduces
toSLEFand helper functions to convert internal build data into SLEF JSON. - Extends the export modal to show, select, and copy the SLEF output, including new CSS, icon, and translations.
- Updates mappings and ship/slot logic to track slot indices and map names correctly for SLEF; includes a fixture for SLEF export tests.
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/less/modal.less | Styles for JSON inputs and .slefbox layout |
| src/app/utils/SLEF.js | toSLEF conversion and helpers for SLEF export |
| src/app/utils/CompanionApiUtils.js | Mappings for bulkheads and core internals used by SLEF |
| src/app/shipyard/Ship.js | Track slotIndex and utility mounts for export |
| src/app/shipyard/ModuleUtils.js | Import formatting cleanup |
| src/app/shipyard/Constants.js | Added RatingToNumber for rating conversion |
| src/app/pages/OutfittingPage.jsx | Pass ship prop to ModalExport for SLEF generation |
| src/app/components/SvgIcons.jsx | New Copy icon for clipboard action |
| src/app/components/ModalExport.jsx | Render SLEF textarea, copy button, and CSS class update |
| src/app/i18n/*.json | Add "copy" translation key in all locales |
| tests/fixtures/valid_exported_slef.json | SLEF export fixture for testing |
Comments suppressed due to low confidence (2)
src/app/utils/SLEF.js:1
- Consider adding unit tests for
toSLEFto verify mapping logic, slot ordering, and behavior when inputs are missing or invalid.
import {
src/less/modal.less:115
- Missing semicolon after
width: 100%. Add;to prevent CSS parsing errors.
width: 100%
|
Thanks for this, I haven't had a chance to look yet, although I have been trying. I will take a proper look as soon as I can. |
|
No worries! I haven't added tests to it yet, if you prefer I can add it here or in another PR because I'll also be off for a few days :) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Howdy! Any updates on this? |
Hi, apologies, I've been working on a long planned feature release all week, so I've unfortunately changed a LOT to do with the core code and haven't yet pushed it back to this repo to look at how that changes the PR. I will be doing soon. |
|
I see, do you think this is going to conflict? If you need an help on that I'm willing to help maintaining here too :) |
Always good to have additional help maintaining this stuff, although I do need to have a think about how we do that. Coriolis is deployed from my fork of the EDCD repo, as that's where I have all of my github runners configured and no one else has control of them. There is a live branch which is the code found on coriolis.io and a beta branch, which has the code found on beta.coriolis.io, forking from either of those branches isn't ideal, as those branches contain workflow scripts, which I don't want to push up to the EDCD upstream repo, so right now, because I'm mid-feature release, it's just a bit awkward trying to merge PR's in where the base for those PR's is either develop, or main, in the EDCD repo. Once this code gets pushed back to EDCD:coriolis on the develop branch, I can look at this PR and the others sat waiting for attention too, but they're definitely going to require a bit of a rework, yours especially, as I notice you've done slot indexing in the PR and I've done slot indexing in my current feature release as well. I did use your indexing code as the base for that, but had to go a step further and make changes to make it work with imports properly... I'll come back to you in hopefully a few days, when I've pushed this code back to develop, but currently the release isn't finished. |
That makes a LOT of sense because I was looking for the commit that added the PCMII and couldn't find it xD all good on my side, I'll wait for your merge then, please lmk when it's landed in main so I can update the stuff for the SLEF builds, then I'll start tackling all the other issues too :) I have some ideas for enhancements that I wanted to apply in the future. |
This fixes #788 and it's a long requested feature. The ability to export SLEF builds in addition to the common internal Coriolis format.
SS:
