-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Move vehicle part variants to json #65871
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irwiss
requested review from
Maleclypse,
KorGgenT and
John-Candlebury
as code owners
May 27, 2023 04:08
github-actions
bot
added
[C++]
Changes (can be) made in C++. Previously named `Code`
[JSON]
Changes (can be) made in JSON
Appliance/Power Grid
Anything to do with appliances and power grid
Code: Tests
Measurement, self-control, statistics, balancing.
Items: Armor / Clothing
Armor and clothing
Items: Battery / UPS
Electric power management
Map / Mapgen
Overmap, Mapgen, Map extras, Map display
Mods: Aftershock
Anything to do with the Aftershock mod
Mods: Innawood 🌲
Anything to do with Innawood mod
Mods: Magiclysm
Anything to do with the Magiclysm mod
Mods: No Hope
Relating to the mod No Hope
Mods: Xedra Evolved
Anything to do with Xedra Evolved
Vehicles
Vehicles, parts, mechanics & interactions
json-styled
JSON lint passed, label assigned by github actions
astyled
astyled PR, label is assigned by github actions
labels
May 27, 2023
irwiss
force-pushed
the
vpart-variants
branch
2 times, most recently
from
May 28, 2023 11:28
19b989f
to
9f8f57b
Compare
github-actions
bot
added
<Documentation>
Design documents, internal info, guides and help.
[Markdown]
Markdown issues and PRs
labels
May 28, 2023
irwiss
force-pushed
the
vpart-variants
branch
2 times, most recently
from
May 29, 2023 21:19
2bd3a95
to
debd73b
Compare
github-actions
bot
added
the
BasicBuildPassed
This PR builds correctly, label assigned by github actions
label
May 29, 2023
irwiss
force-pushed
the
vpart-variants
branch
2 times, most recently
from
May 30, 2023 18:18
0f6e5f7
to
56ba440
Compare
github-actions
bot
removed
the
BasicBuildPassed
This PR builds correctly, label assigned by github actions
label
May 30, 2023
irwiss
changed the title
(WIP) Move vehicle part variants to json
Move vehicle part variants to json
May 30, 2023
github-actions
bot
added
the
BasicBuildPassed
This PR builds correctly, label assigned by github actions
label
Jun 1, 2023
irwiss
force-pushed
the
vpart-variants
branch
2 times, most recently
from
June 2, 2023 17:57
9a2c177
to
f249835
Compare
Fris0uman
reviewed
Jun 6, 2023
irwiss
force-pushed
the
vpart-variants
branch
2 times, most recently
from
June 6, 2023 13:48
98b6bab
to
2eb5ddf
Compare
This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there: https://discourse.cataclysmdda.org/t/changes-to-vehicle-welding/28799/1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Appliance/Power Grid
Anything to do with appliances and power grid
astyled
astyled PR, label is assigned by github actions
BasicBuildPassed
This PR builds correctly, label assigned by github actions
[C++]
Changes (can be) made in C++. Previously named `Code`
Code: Tests
Measurement, self-control, statistics, balancing.
<Documentation>
Design documents, internal info, guides and help.
Items: Armor / Clothing
Armor and clothing
Items: Battery / UPS
Electric power management
[JSON]
Changes (can be) made in JSON
json-styled
JSON lint passed, label assigned by github actions
Map / Mapgen
Overmap, Mapgen, Map extras, Map display
[Markdown]
Markdown issues and PRs
Mods: Aftershock
Anything to do with the Aftershock mod
Mods: Innawood 🌲
Anything to do with Innawood mod
Mods: Magiclysm
Anything to do with the Magiclysm mod
Mods: No Hope
Relating to the mod No Hope
Mods: Xedra Evolved
Anything to do with Xedra Evolved
[Python]
Code made in Python
Translation
I18n
Vehicles
Vehicles, parts, mechanics & interactions
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
None
Purpose of change
Move hardcoded variants and the stuff that works around the fact that variants are hardcoded into normal json
Fixes #64827
Describe the solution
JSON changes are mostly done by script, can be found in dev branch. The script is a bit of a mess but looks to be doing the correct changes (it prints most changes it makes).
Makes variants field for vparts, collects all the symbol/broken_symbol/symbols fields into it, each object in it defines a variant with a unique id, label for translation, symbol and symbol broken. At least 1 variant is required per part, the first variant is defaulted to if no variant is specified.
symbols define either string of 1 character for non-rotating or 8 characters for rotating; where first character = north, second = NE, third = E etc
The symbols are normal ascii, a small amount of unicode box drawing symbols are accepted for the lines and corners, which get translated in code to curses ACS, json modders can human-read them and copy/paste instead of remembering which vi-like key is which corner/direction
Variants in vehicle prototypes were split by
_
which makes splitting to id and variant a bit of guesswork; depends on specific variant order and relies on not defining specific strings as part of part id, they are now split by#
character (it is now also an error to use it in vpart id), so there's no guesswork involvedBy stuff that works around hardcoded variants I mean the windowshield_full, saddle_scooter etc - parts that are exactly the same but have different id to work around the hardcoded variants map. They are migrated to their "normal" vpart with variant name prepended with
_full
,_scooter
etc. To do this thevariants_base
field is used - it defines a list of prefixes, which are then cartesian multiplied by them, e.g. wheel_small defines"variants_base": ["scooter"]
, and front/rear in variants; this will generate variants for [front, rear, scooter_front, scooter_rear].Tilesets shouldn't require an update for the most part except for minor string replaces as some ids didn't fit with the rest of the ids:
seat_windshield_leather
->seat_leather_windshield
reclining_seat_windshield_leather
->reclining_seat_leather_windshield
Variants also perform a small looks_like search - each resolution failure will chop off right side of the string until a
_
, so whenreclining_seat_leather_windshield
is not present in a tileset looks_like will search for reclining_seat_leather and then fallback to reclining_seat (no variant tile)Describe alternatives you've considered
Reorder the fields while i'm at it, vpart definitions are super annoying to read when you have to search top to bottom for the type/abstract/id/copy-from fields which appear all over the place, the price is 4 more files and around +500 -500 lines in the diff, but gave up as PR is already super chonk
Testing
There's part dumps in the dev branch master...irwiss:Cataclysm-DDA:vpart-variants-dev but most changes are visual so the game needs to be run
There might be minor hiccups but main tilesets tested - MSXotto, Ultica work correctly
smashbutton iso also worked correctly, i didn't notice changes in level of brokenness in ultica_iso
For non-tiles there seems to be some small issues related to symbols for parts that have no variants, e.g. small battery appliance defines
b
for symbol, which made it draw a corner rather thanb
letter, now draws ab
, freezer wasH
which was drawn as=
, now it is draws an actualH
character, but they should be solvable with later PRs, if they are in fact incorrect and not mistakesLoading older saves also seems to be working, migrations aren't 100% lossless - the _full variants convert to default "full" variant, the difference should be trivial to fix vs a non trivial amount of migration entries to generate otherwise
Additional context
Apparently not the first time this is looked at https://discord.com/channels/598523535169945603/598529174302490644/690345214736728269
Player-facing stuff should mostly remain the same, there's no "base"s to choose, instead every cosmetic variant is similar to any other
Backup of the python script as I'm deleting the dev branch: